如何使用图形api获取用户的facebook帖子?

时间:2013-11-20 09:56:59

标签: facebook facebook-graph-api facebook-javascript-sdk

我尝试使用以下代码来获取使用我的应用的用户的帖子。但是,我在第二种情况下发生错误,同时试图发布到用户的墙壁和检索帖子,我只有数据和分页。

FB.api('/platform/posts', { limit: 3 }, function(response) {
        console.log('Good to see you, ' + response.length);
      for (var i=0, l=response.length; i<l; i++) {
        var post = response[i];
        console.log('Good to see you, ' + post);
        /*if (post.message) {
          alert('Message: ' + post.message);
        } else if (post.attachment && post.attachment.name) {
          alert('Attachment: ' + post.attachment.name);
        }*/
      }
    });

    var body = 'Reading JS SDK documentation';
    FB.api('/me/feed', 'post', { message: body }, function(response) {
      if (!response || response.error) {
        alert('Error occured');
      } else {
        alert('Post ID: ' + response.id);
      }
    });  

出了什么问题?

在第二个块中,显示警告“发生错误”。在第一个块中,发生以下错误:

__d("sdk.ErrorHandling",   ["sdk.feature","ManagedError","sdk.Runtime","sdk.Scribe","UserAgent","wrapFunction"],function(a,b,c,d,e,f){var g=b('sdk.feature'),h=b('ManagedError'),i=b('sdk.Runtime'),j=b('sdk.Scribe'),k=b('UserAgent'),l=b('wrapFunction'),m=g('error_handling',false),n='';function o(u){var v=u._originalError;delete u._originalError;j.log('jssdk_error',{appId:i.getClientID(),error:u.name||u.message,extra:u});throw v;}function p(u){var v={line:u.lineNumber||u.line,message:u.message,name:u.name,script:u.fileName||u.sourceURL||u.script,stack:u.stackTrace||u.stack};v._originalError=u;if(k.chrome()&&/([\w:\.\/]+\.js):(\d+)/.test(u.stack)){v.script=RegExp.$1;v.line=parseInt(RegExp.$2,10);}for(var w in v)(v[w]==null&&delete v[w]);return v;}function q(u,v){return function(){if(!m)return u.apply(this,arguments);try{n=v;return u.apply(this,arguments);}catch(w){if(w instanceof h)throw w;var x=p(w);x.entry=v;var y=ES5(Array.prototype.slice.call(arguments),'map',true,function(z){var aa=Object.prototype.toString.call(z);return (/^\[object (String|Number|Boolean|Object|Date)\]$/).test(aa)?z:z.toString();});x.args=ES5('JSON','stringify',false,y).substring(0,200);o(x);}finally{n='';}};}function r(u){if(!u.__wrapper)u.__wrapper=function(){try{return u.apply(this,arguments);}catch(v){window.setTimeout(function(){throw v;},0);return false;}};return u.__wrapper;}function s(u,v){return function(w,x){var y=v+':'+(n||'[global]')+':'+(w.name||'[anonymous]'+(arguments.callee.caller.name?'('+arguments.callee.caller.name+')':''));return u(l(w,'entry',y),x);};}if(m){setTimeout=s(setTimeout,'setTimeout');setInterval=s(setInterval,'setInterval');l.setWrapper(q,'entry');}var t={guard:q,unguard:r};e.exports=t;});  

谢谢

0 个答案:

没有答案