问题描述
我正在尝试制作一个Facebook视频应用程序,以便用户可以使用Facebook Open Graph在自己的墙上显示存储在我网站上的视频.
I'm trying to make a Facebook video application so users can have a video stored on my site displayed on their wall using Facebook Open Graph.
我正在使用以下代码进行用户登录.
I'm using the below code for user login.
<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>
现在如何执行监视"操作?
Now how do I implement the Watch action?
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中?以及如何获取用户的访问令牌?
in PHP? And how can I get the access token of users?
推荐答案
要获取PHP SDK 3.1.1中的用户访问令牌:
To get the user access token in PHP SDK 3.1.1:
// Get the current access token
$access_token = $facebook->getAccessToken();
请参阅: https://developers.facebook.com/docs/参考/php/facebook-getAccessToken/
发布操作.
请参阅: https://developers.facebook.com/docs/opengraph/tutorial/
本教程将指导您完成构建,测试和发布第一个Open Graph应用程序的关键步骤.我们将构建一个示例食谱应用程序,该应用程序允许用户发布有关烹饪食谱的故事.在开始之前,请查看打开图形检查表",它不仅可以帮助您设计和规划应用程序,而且还可以加快应用程序的审查过程.
This tutorial will guide you through the key steps to build, test, and publish your first Open Graph application. We will build a sample recipe application that allows users to publish stories about cooking recipes. Before starting, please review the Open Graph Checklist which will not only help in your app design and planning, but will also help speed up the application review process.
第1步:创建一个Facebook应用程序. https://developers.facebook.com/docs/opengraph/tutorial/#create -app
Step 1: Create a Facebook applications. https://developers.facebook.com/docs/opengraph/tutorial/#create-app
第2步:使用登录按钮"插件对用户进行身份验证. https://developers.facebook.com/docs/opengraph/tutorial/#authenticate
Step 2: Authenticate users with the Login Button plugin. https://developers.facebook.com/docs/opengraph/tutorial/#authenticate
第3步:通过App信息中心定义对象,操作和集合. https://developers.facebook.com/docs/opengraph/tutorial/#define
Step 3: Define Objects, Actions and Aggregations through the App Dashboard. https://developers.facebook.com/docs/opengraph/tutorial/#define
第4步:为您的用户发布操作. https://developers.facebook.com/docs/opengraph/tutorial/#publish
Step 4: Publish Actions for your users. https://developers.facebook.com/docs/opengraph/tutorial/#publish
第5步:将社交插件添加到您的应用程序. https://developers.facebook.com/docs/opengraph/tutorial/#plugins
Step 5: Add Social Plugins to your application. https://developers.facebook.com/docs/opengraph/tutorial/#plugins
第6步:提交您的操作以供批准. https://developers.facebook.com/docs/opengraph/tutorial/#submit
Step 6: Submit Your Actions for approval. 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);
这篇关于Facebook Open Graph观看动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!