【问题标题】:post to users wall with js用js发布到用户墙
【发布时间】:2012-07-19 18:38:47
【问题描述】:

我们有一个评论板,我们希望允许我们的用户将他们的帖子交叉发布到他们的 Facebook 墙上。我们已经将他们的用户帐户连接到他们的 Facebook 帐户,以便获取他们的 Facebook 个人资料照片,并且工作正常。

我尝试按照此处的指南 (https://developers.facebook.com/docs/reference/dialogs/feed/) 进行操作,第一个示例运行良好,但我们真的不希望出现对话框,所以我尝试了“Graph API Equivalent”,但不断收到 oauth 异常 #200(“此 API 调用需要有效的 app_id。”)。

我检查了 FB.getLoginStatus 并且我已连接并执行 FB.getAccessToken() 给了我一个访问令牌。

我没有得到什么?

编辑

是的,代码......现在我有这个:

<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
    appId : 'APP_ID',
    status : true,
    cookie : true,
    xfbml : true
});
FB.UIServer.setLoadedNode = function(a,b){FB.UIServer._loadedNodes[a.id]=b;};
};
(function(d){
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
}(document));

</script>

我可以获得访问令牌并验证登录的 Facebook 用户(我)已连接到与 app_id 匹配的应用。

我还可以使用带有 stream.publish 方法的 FB.ui 调用消息对话框。

我想不通的是,如何在不弹出消息对话框的情况下透明地将我的本地评论发布到我的 Facebook 页面。

任何指针?

提前谢谢你:-) 马丁

【问题讨论】:

标签: javascript facebook facebook-oauth


【解决方案1】:

马丁,

function shareWithFacebook() {
      var photoName;
      var photoUrl;
      photoName = document.getElementById("ImageName").value;
      photoUrl = document.getElementById("ImageUrl").value;
      debugger;
      var ui;
      var publish;
      FB.getLoginStatus(function (response) {
          FB.api('/me/feed', 'post', {
              message: 'I just added an image of ' + photoName + ' on http://www.yoursite.com/',
              name: photoName,
              link: 'http://www.yoursite.com/',
              picture: photoUrl,
              actions: [{ name: 'Photo', link: 'http://www.yoursite.com/'}]

          }, function (response) {
              if (!response || response.error) {
                  alert('Couldn\'t post to Facebook!');
              }
              else {
                     alert('الحمد لله');
              }
          }

                     );
      });
  }          

【讨论】:

  • 我才意识到我忘了感谢您的帮助...? 谢谢 :-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-22
  • 1970-01-01
  • 2011-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多