简体   繁体   English

Facebook API:如何发布到页面墙

[英]Facebook API: How to post to a page wall

It's the same situation as here , but now I need to post a message to the wall of a Facebook Page . 这与此处的情况相同,但现在我需要在Facebook 页面的墙上发布消息。

I tried the following (the other code is the same as in the answer): 我尝试了以下(其他代码与答案中的相同):

$facebook->api('/PAGE-ID/feed', 'post', $attachment)

But I get the error 但是我得到了错误

(#200) The user hasn't authorized the application to perform this action`. (#200)用户尚未授权应用程序执行此操作。

I think I have the wrong access_token for that action but where/how do I get the correct? 我认为我对该操作有错误的access_token ,但我在哪里/如何获得正确的?

Facebooks documentation on obtaining access_tokens and permissions is documented on their site Here . 在获得access_tokens和权限Facebook的文档在其网站上记录在这里

You will need to obtain a permanent access_token with the permissions to post to the users status page if you want to post offline. 如果要脱机发布,则需要获取具有发布到用户状态页面权限的永久 access_token。 You must have the permanent (or offline_access) token in order to do this without worrying about the token expiring. 您必须拥有永久(或offline_access)令牌才能执行此操作,而不必担心令牌过期。

When requesting an access_token you can add an additional permissions attribute to the GET request that is issued, in that key you specify the additional permissions you would like. 请求access_token时,您可以向发出的GET请求添加其他权限属性,在该密钥中指定您想要的其他权限。

EDIT: The process for obtaining a token with scope permission is here , under the section "Authorization" look at the second example. 编辑:获取具有范围权限的令牌的过程在此处 ,在“授权”部分下查看第二个示例。 It will have a "scope" sample requesting additional permissions. 它将有一个“范围”示例请求其他权限。 The permissions used to be documented in the OAuth flow, but they seem to have moved, sorry. 过去曾经在OAuth流中记录了权限,但它们似乎已经移动了,抱歉。

That error message sounds more like you have an access token, but the permissions are wrong. 该错误消息听起来更像是您有访问令牌,但权限是错误的。 Read up on extended permissions 阅读扩展权限

You probably need to ask for "publish_stream" when your user logs in/gives permissions on your "app". 当您的用户登录/授予“app”权限时,您可能需要请求“publish_stream”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM