在FB的JavaScript SDK,
- * FB儀表盤 - > Open Graph的
- 創建一個故事
- 列表項確保啓用了 '能力'在你的動作類型中有諸如-tags,-user消息,-place等功能。
- *在你的js
1.調用JS SDK
window.fbAsyncInit = function() {
FB.init({
appId : {YOUR_APP_ID} , // App ID
version: 'v2.0',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
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/sdk.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
}
3.登錄到FB與這些領域要求
function Login()
{
FB.login(function(response) {
if (response.authResponse)
{
console.log(response.authResponse); // Get User Information.
} else
{
console.log('Authorization failed.');
}
},{scope: 'user_friends, publish_actions, status_update, read_stream, manage_friendlists'});// ' user_interests, user_likes, etc.. '
}
4 。獲取記錄的用戶taggable_friends功能如:
var var friendsIDarray = [];
var user_friend_list;
function meTaggableFriends(){
FB.api(
"/me/taggable_friends",
function (response) {
if (response && !response.error) {
/* handle the result */
console.log(response)
for(var i=0; i<response.data.length; i++){
var data = response.data;
friendsIDarray.push(data[i].id);
}
user_friend_list = friendsIDarray.join();
}
}
);
5.現在,我們已經保存在該單詞的id在user_friend_list因爲我們希望在我們的後 來標記那些朋友,我們可以使用這樣的Open Graph的行動,以標籤的朋友:
FB.api(
'me/{namespace}:{action}',
'post',
{
{object-type}:'http://example.com/object/', // make sure to have the apropiate og:type meta set
place:'https://example.com/place/', // open graph page with metas for location, id for a location page etc
tags: user_friend_list, // the tokens ids for those friens you wanna tag and you got on previous step
title: 'whatever',
message: 'like this, you tag friends @['+ONE_TOKEN_ID_FROM_TAGGABLE_FRIENDS+'] , @['+ONE_TOKEN_ID_FROM_TAGGABLE_FRIENDS+'] etc'
},
function(response) {
console.log(response)
}
);
,你可以找到關於它的更多信息:
https://developers.facebook.com/docs/opengraph/using-actions/v2.1
希望你覺得它有用。
你有沒有至少發表過一次自己的動作? – WizKid
@WizKid我試試。但我想知道如何設置? – user3788899
如果您嘗試將其提交以供審覈,則會出現該錯誤。你不需要提交它來檢查它 – WizKid