aka*_*hic 5 php facebook facebook-graph-api
我想使用PHP发布到Facebook页面墙作为页面.我通过以下链接获得了access_token.
https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=123456789&redirect_uri=http%3A%2F%2Fmysite.net&scope=publish_stream,manage_pages,offline_access
https://graph.facebook.com/me/accounts?access_token=...
Run Code Online (Sandbox Code Playgroud)
我正在使用这个简单的代码:
$appid = "";
$secret = "";
$pageid = "";
$access_token = "";
require_once("facebook-php-sdk/src/facebook.php");
$facebook = new Facebook(array(
'appId' => $appid,
'secret' => $secret
));
try {
$args = array(
'access_token' => $access_token,
'message' => 'Test',
'link' => 'http://www.test.com',
'description' => 'Test'
);
$post_id = $facebook->api("/$pageid/feed","post",$args);
} catch (FacebookApiException $e) {
error_log($e);
}
Run Code Online (Sandbox Code Playgroud)
这就是我得到的错误:
OAuthException: (#200) Posts where the actor is a page cannot also include a target_id
Run Code Online (Sandbox Code Playgroud)
但是发布/ me/feed也不会起作用.我用Google搜索的所有解决方案都不起作用,官方文档没有帮助.我在以用户(不是页面)和javascript api(用户需要'共享'点击操作)发布时使用它.
任何人都知道自动发布到fb页面作为页面的解决方案?花了几个令人沮丧的日子试图弄明白-_-
谢谢,
一个.
页面无法发布到用户的墙上(这就是为什么你会OAuthException说"作为页面,你不能设置target_id").您必须首先创建一个应用程序并获得用户的许可(publish_stream)以通过该应用程序发布到他们的Feed.
| 归档时间: |
|
| 查看次数: |
6868 次 |
| 最近记录: |