0

//更新:在帮助下,我设法捕获了一些修复令牌问题的错误。我已经更新了代码以反映这一点。不过,代码仍然不会在时间线上产生事件,所以我把问题留了下来。

原始问题:

我正在尝试使用 Open Graph API 构建一个简单的脚本,一旦访问者点击该页面,它将向 Facebook 推送指向已访问页面(包含电影)的链接。

我没有使用自定义操作和对象,而是使用标准 Watch 操作 (https://developers.facebook.com/docs/opengraph/video/) 和 Video.movi​​e 对象。

我根据FB的示例代码提出了这个:

<!-- first login-button with scope publish_actions: -->
<fb:login-button show-faces="false" width="200" max-rows="1" scope="publish_actions"    ></fb:login-button>

<!-- Then script that should push update to timeline: -->
<script type="text/javascript">
    function fbPublish(){
        FB.api(
        '/me/video.watches',
        'post',
        { 'video.movie': '<?php the_permalink(); ?>',
        'access_token': 'blablabla'  },
        function(response) {
           if (!response || response.error) {
              alert('Nope.');
           } else {
              alert('Yes.'); // any stuff
           }
        });
    }

这会触发警报“不”。

我已经通过 curl 添加了 Watch 动作。关于可能发生什么的任何想法?

4

1 回答 1

0

You still need to FB.login before you can automatically post to the user's timeline.

FB.login(function(response) {
      // Post the action
 }, {scope: 'publish_actions'});

While I didn't check the validity of your actual code to post the action, you problem is that before you can do this, you'll need the user's permission. The publish_actions permission is the one you'll need but I think its already included in new Auth Dialogs. Just leave it there to be sure.

Do the FB.login code first, you'll get a popup "Allow" dialog, after that, is the time you can freely post in the user's wall. It's a part of the security, Facebook users wouldnt want you posting on their timeline without them knowing.

于 2012-05-16T00:26:51.710 回答