Facebook应用程序拉网站的帖子不工作

时间:2016-05-25 03:23:06

标签: facebook facebook-graph-api

我正试图从Facebook上传帖子到我的网站。我创建了一个相同的Facebook应用程序(https://www.facebook.com/kcm.edu.np/)。 代码:

$(document).ready(function() {
    var accessToken ='975498622499311|eKS53jkWW4F74JEShrDHuJNwOwg';
    $.ajax({
        url: 'https://graph.facebook.com/v2.5/kcm.edu.np/posts?fields=full_picture,id,is_published,link,story,message,name,updated_time,description,from,source,caption,created_time,permalink_url,type,target&access_token=' + accessToken + '&limit=6',
        type: 'GET',

        success:function(result){
            $("#hidden-next-feed").val(result.paging.next);
            $.each( result.data, function( index, value ) {
                var link;
                var imgSrc = '';
                var name = '';
                var message = '';
                if(typeof(value.link) != "undefined" && value.link !== null) {
                    link = value.link;
                } else {
                    link = value.permalink_url;
                }
                if(typeof(value.full_picture) != "undefined" && value.full_picture !== null) {
                    imgSrc = value.full_picture;
                }
                if(typeof(value.name) != "undefined" && value.name !== null) {
                    name = value.name;
                }
                if(typeof(value.message) != "undefined" && value.message !== null) {
                    message = value.message;
                }
                $("#facebook-feed").append(
                    '<div class="grid-item"><a href="'+value.permalink_url+'" target="_blank">'+
                    '<div class="thumbnail">'+
                    '<img src="'+imgSrc+'" alt="'+name+'" >'+
                    '<div class="caption">'+
                    '<h3>'+name+'</h3>'+
                    '<p>'+message+'</p>'+
                    '</div>'+
                    '</div>'+
                    '</a></div>'
                );
            });
            $container.masonry('destroy');
            $container.imagesLoaded(function(){
                $container.masonry({
                    itemSelector: '.grid-item',
                    percentPosition: true
                });
            });
        },
        error:function() {
            $("#facebook-feed").html('Failed To Load Resource');
        }
    });
});

问题:

{
   "error": {
      "message": "Unsupported get request. Object with ID 'kcm.edu.np' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
      "type": "GraphMethodException",
      "code": 100,
      "fbtrace_id": "FsBLqadb5Oz"
   }
}

我如何解决这个问题?欢迎任何帮助/建议。提前谢谢。

2 个答案:

答案 0 :(得分:0)

页面可见性的设置需要设置为&#34;每个人都可以看到&#34;。此选项可在 - 设置&gt;下找到。一般&gt;国家限制。

请试一试。

答案 1 :(得分:0)

  1. 您应该从不在客户端显示App Secret,而是使用PHP sdk并向服务器发出ajax请求。作为@WizKid 说,
  2.   

    应始终将应用程序密钥视为您的密码

    - 没有做到     这可能会导致您的帐户和应用受到损害。尽快重置。

    1. 检索网页帖子的正确方法是访问Feed端点:

      /<id>/feed?fields=<fields>

    2. 在您的情况下,页面的ID是:1451944358387272