我正在尝试使用 FB api 发布到 FB 页面。帖子通过正常,但它只对管理员用户可见,而不是所有喜欢该页面的人。我尝试使用 EVERYONE & ALL_FRIENDS 更改隐私设置,但没有太大帮助。下面是我的代码片段。
任何帮助都非常感谢。
//--------code snippet------------
require '../src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'XXXXXXXXXXXX',
'secret' => 'YYYYYYYYYYYYYYYYYYY',
));
// Get User ID
$user = $facebook->getUser();
if ($user)
{
try {
$page_id = 'ZZZZZZZZZZZ';
$page_info = $facebook->api("/$page_id?fields=access_token");
if( !empty($page_info['access_token']) )
{
$args = array(
'access_token' => $page_info['access_token'],
'message' => "My Msgs!"
);
$post_id = $facebook->api("/$page_id/feed","post",$args);
}
else
{
$permissions = $facebook->api("/me/permissions");
if( !array_key_exists('publish_stream', $permissions['data'][0]) ||
!array_key_exists('manage_pages', $permissions['data'][0]))
{
$loginUrl = $facebook->getLoginUrl(array("scope" => "publish_stream, manage_pages"));
echo '<a href="'.$loginUrl.'">Login1 with FB</a>';
}
}
} catch (FacebookApiException $e)
{
echo "error ", $e;
}
}
if ($user)
{
$logoutUrl = $facebook->getLogoutUrl();
} else
{
$loginUrl = $facebook->getLoginUrl(array('scope'=>'manage_pages,publish_stream'));
echo '<a href="'.$loginUrl.'">Login2 with FB</a>';
}