我正在嘗試使用此代碼發佈給我的朋友的提要,但它不起作用。我卡住了,有什麼幫助?如何使用php sdk發佈在朋友的牆上?
$app_url ="http://localhost.local/PMS/facebook/PostWithPHP.php";
$facebook = new Facebook(array(
'appId' => 'APPID',
'secret' => 'APPSECRET',
'cookie' => true,
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
$user_friends = $facebook->api('/me/friends');
sort($user_friends['data']);
try {
// Proceed knowing you have a logged in user who's authenticated.
$access_token = $facebook->getAccessToken();
$vars = array(
'message' => 'My Message',
'name' => 'title',
'caption' => 'Caption',
'link' => 'Link',
'description' => 'Description',
'picture' => 'image'
);
foreach($user_friends['data'] as $f){
$sendTo = $f['id'];
$sendToName = $f['name'];
$result = $facebook->api("/".$sendTo ."/feed", 'post', $vars);
}
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array('redirect_uri'=> $app_url));
echo "<script type='text/javascript'>";
echo "top.location.href = '{$loginUrl}';";
echo "</script>";
}
,另一個問題是,使用這種代碼,但與替換$ facebook-> API( 「/".$ SENDTO。」/進料」, '後',$ VARS); by $ facebook-> api(「/ me/feed」,'post',$ vars);當然沒有循環播放朋友,我的時間表上的帖子。我怎麼能讓它發佈在我的牆上?
毫米有意義,所以你認爲有沒有解決方案? – user1395625