FB GraphAPI:从另一个网站在 FB 页面上发布
我正在为网站创建 CMS,并且想要添加功能以将某些内容(例如:新闻)发布到该网站的 FB 页面 [而不是用户个人资料]。
我已阅读 FB 的文档,并且发现我需要一个 FB 应用程序,该应用程序必须有权访问该页面。然后,我将能够从我的网站作为应用程序进行身份验证,并将链接发布到页面上。
我创建了示例页面和一个空应用程序(没有工作代码)。然后我将其添加到页面[在应用程序配置文件页面上有一个按钮“添加到我的页面”]。应用程序从未请求任何权限,事实上,我不知道如何“强制”我的应用程序从页面请求权限...
现在,从我的服务器我作为应用程序进行身份验证:
$postArr = Array(
'grant_type'=>'client_credentials',
'scope'=>'publish_stream',
'client_id'=>$appId,
'client_secret'=>$appSecret
);
$access_token = CURL_post('https://graph.facebook.com/oauth/access_token',$postArr,true);
我得到一个访问令牌,并尝试发布到主页墙上:
$postArr = Array(
'access_token'=>$access,
'message'=>"Message!",
'link'=>'http://egern.net/',
'name'=>"TITLE",
'caption'=>"TITLE2!");
$r = CURL_post("https://graph.facebook.com/MYPAGEID/feed",$postArr,true);
我收到以下错误:(#200) 用户尚未授权应用程序执行此操作
现在我无法理解:主页应如何授权应用程序?
谢谢。
I'm creating a CMS for a website, and want to add functionality to post something (for example: news) to that website's FB Page [not to a user profile].
I've read FB's documentation, and could find out that I need to have a FB application, which must have access to that Page. Then I'll be able to authenticate from my website as Application and post the link on the Page.
I've created sample Page, and an empty Application (no working code). Then I've added it to the Page [on App Profile Page there is a button "Add to my page"]. The Application never requested any permissions, and, in fact, I don't know how can I "force" my App to request permissions from Page...
Now, from my server I'm authenticating as Application:
$postArr = Array(
'grant_type'=>'client_credentials',
'scope'=>'publish_stream',
'client_id'=>$appId,
'client_secret'=>$appSecret
);
$access_token = CURL_post('https://graph.facebook.com/oauth/access_token',$postArr,true);
I get an Access Token, and try to post to the Page's wall:
$postArr = Array(
'access_token'=>$access,
'message'=>"Message!",
'link'=>'http://egern.net/',
'name'=>"TITLE",
'caption'=>"TITLE2!");
$r = CURL_post("https://graph.facebook.com/MYPAGEID/feed",$postArr,true);
I get following error: (#200) The user hasn't authorized the application to perform this action
Now I can't understand: how should the Page authorize the Application?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了能够使用图形 API 发布到您的页面,需要执行以下几个步骤:
manage_pages
、参考。和第 3 步的publish_stream
->api('/me/accounts?access_token=XXX')
将检索您的所有页面(帐户)及其相应的 access_token->api('/page_id/feed', 'post', $postArr)
几乎可以使用相同的说明 此处。
To be able to post to your page using the graph api there's a couple of steps to do this:
manage_pages
, reference. Andpublish_stream
for step 3->api('/me/accounts?access_token=XXX')
with the access_token you just obtained will retrieve all your pages (accounts) with their corresponding access_token->api('/page_id/feed', 'post', $postArr)
Almost same instructions are available here.