0
我已经在Facebook上创建了一个应用程序,并且在php sdk之间,我可以在我的个人资料上发布我的网站文章。我想在我的粉丝页上发布我的网站
现在,我想发布我的文章在我的粉丝页,而不是在我的prfile。我怎么能做到这一点?
这是我使用,从例如没有太大的不同在Facebook开发代码:Oviusly的“XXXX”用于隐私
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('facebook.php');
$config = array(
'appId' => 'xxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxx',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<?
if($user_id) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
$access_token = $facebook->getAccessToken();
$page_id='xxxxxxxxxxxxxx';
$ret_obj = $facebook->api('/me/feed', 'POST',
array(
'link' => $link,
'message' => $titolo,
'picture' => 'http://xxxxxxxxxxxxxxxxxx',
'name' => 'Ecosport',
'access_token' => $access_token
));
echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl(array(
'scope' => 'publish_stream'
));
header("location:$login_url");
error_log($e->getType());
error_log($e->getMessage());
}
// Give the user a logout link
$id_articolo=$_GET['id_articolo'];
header("location:xxxxxxxxxx");
/*echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';*/
} else {
// No user, so print a link for the user to login
// To post to a user's wall, we need publish_stream permission
// We'll use the current URL as the redirect_uri, so we don't
// need to specify it here.
$login_url = $facebook->getLoginUrl(array('scope' => 'publish_stream'));
header("location:$login_url");
/*echo 'Please <a href="' . $login_url . '">login.</a>';*/
}
?>
。我绑并改变这个“$ facebook-> api('/ me/feed',......”到这个“$ facebook-> api('/ $ page_id/feed',....... “但什么都没有。我不能发表我的文章,我的粉丝专页。
你能帮助我吗?
非常感谢你。
请参阅https://developers.facebook.com/docs/authentication/ – DMCS 2011-12-30 01:28:57
的页面登录部分,该页面以用户的身份发布到粉丝页面。您是否知道如何将它发布到粉丝页面*作为粉丝页面?* – 2011-12-30 17:52:56
不,我的上述解释不会以用户身份发布到流中,因为它使用页面的访问令牌,所以会将其作为页面发布。 – DMCS 2011-12-30 18:44:26