[英]FB GraphAPI: Posting on FB page's wall from another website
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]. 我正在为网站创建CMS,并希望添加功能以将某些内容(例如新闻)发布到该网站的FB页面[而不是用户个人资料]。
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. 我已经阅读了FB的文档,并发现我需要一个FB应用程序,该应用程序必须有权访问该页面。 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 我收到以下错误消息:(#200)用户未授权应用程序执行此操作
Now I can't understand: how should the Page authorize the Application? 现在我不明白:页面应如何授权应用程序?
Thanks. 谢谢。
To be able to post to your page using the graph api there's a couple of steps to do this: 为了能够使用图形API发布到您的页面,有几个步骤可以做到这一点:
manage_pages
, reference . manage_pages
( 参考)权限安装您的应用程序。 And publish_stream
for step 3 publish_stream
步骤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('/me/accounts?access_token=XXX')
将检索所有具有相应access_token的页面(帐户) ->api('/page_id/feed', 'post', $postArr)
->api('/page_id/feed', 'post', $postArr)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.