Facebook Open Graph Watch action


Facebook Open Graph Watch action

我正在尝试制作一个Facebook视频应用程序,以便用户可以使用Facebook Open Graph将存储在我网站上的视频显示在他们的墙上。

我使用以下代码进行用户登录。

<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : 'MYAPPID', // App ID
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
        });
    };
    // Load the SDK asynchronously
    (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>

现在如何实现监视操作?

curl -F 'access_token=myaccesstoken' '
 -F 'movie=http://samples.ogp.me/453907197960619' '
    'https://graph.facebook.com/me/video.watches'

而这个

curl 'https://graph.facebook.com/me/video.watches?access_token=myaccesstoken'

在PHP中?如何获取用户的访问令牌?

要在 PHP SDK 3.1.1 中获取用户访问令牌,请执行以下操作:

// Get the current access token
$access_token = $facebook->getAccessToken();

参考: https://developers.facebook.com/docs/reference/php/facebook-getAccessToken/


发布操作。

参考: https://developers.facebook.com/docs/opengraph/tutorial/

本教程将指导您完成构建、测试和发布第一个 Open Graph 应用程序的关键步骤。我们将构建一个示例食谱应用程序,允许用户发布有关烹饪食谱的故事。在开始之前,请查看开放图形清单,这不仅有助于您的应用设计和规划,还有助于加快申请审核过程。

第 1 步:创建 Facebook 应用程序。 https://developers.facebook.com/docs/opengraph/tutorial/#create-app

第 2 步:使用登录按钮插件对用户进行身份验证。 https://developers.facebook.com/docs/opengraph/tutorial/#authenticate

第 3 步:通过应用程序仪表板定义对象、操作和聚合。 https://developers.facebook.com/docs/opengraph/tutorial/#define

步骤 4:为用户发布操作。 https://developers.facebook.com/docs/opengraph/tutorial/#publish

第 5 步:将社交插件添加到您的应用程序。 https://developers.facebook.com/docs/opengraph/tutorial/#plugins

第 6 步:提交您的操作以供批准。 https://developers.facebook.com/docs/opengraph/tutorial/#submit

例:

if ($user){
    $queries = array(
        // The URL build is me/ namespace : action ? object = URL
        array('method' => 'POST', 'relative_url' => '/me/anotherfeed:view?feed=http://anotherfeed.com/')
        // Any other API calls needed, this is a batch request for performance.
    );
    try {
        $postResponseA = $facebook->api('?batch='.json_encode($queries), 'POST');
    }
    catch (FacebookApiException $e) {
        //echo 'AF error: '.$e.'';
    }
    // Returns the id of posted actions if true.
    $actions = json_decode($postResponseA[0][body], true);