[英]How to post to the wall like the admin of a page using the Facebook JavaScript SDK?
[英]Is it possible to post to pages that you are an admin for using the Facebook Javascript SDK?
我可以在自己的牆上寫字,但不能在我作為管理員的頁面牆上寫字。 我正在使用下面的代碼(JavaScript SDK):
FB.ui(
{
method: 'stream.publish',
message: 'getting educated about Facebook Connect',
attachment: {
name: 'Connect',
caption: 'The Facebook Connect JavaScript SDK',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
href: 'http://github.com/facebook/connect-js'
},
action_links: [
{ text: 'Code', href: 'http://github.com/facebook/connect-js' }
],
user_message_prompt: 'Share your thoughts about Connect',
target_id: '170500829645508',
uid: '100001920038281'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
目標ID是我管理的頁面,而uid是我的帳戶用戶ID。 當我運行此代碼時,我不斷收到錯誤消息:
指定了無效的目標:170500829645508。目標必須是參與者可以在其牆上張貼的頁面,事件或用戶。
我在這里做錯什么了嗎?
您需要manage_pages擴展權限才能執行此操作。 授予權限后,您可以查詢graph.facebook.com/me/accounts來檢索可以發布到頁面牆的API令牌。 在此處查看Facebook的擴展權限: http : //developers.facebook.com/docs/authentication/permissions 。
我最終使用了這種方法,該方法適用於發布到我管理的頁面。 雖然還沒有弄清楚如何以這種方式包括附件...
var wallPost = {
access_token: ".........................",
message: 'Here is some more stuff'
};
FB.api('/me/feed', 'post', wallPost, function(response) {
if (!response || response.error) {
alert('Error occurred:' + response.error.message);
} else {
alert('Success!');
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.