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