-1
在我開發Facebook應用程序時,出現以下錯誤,我無法更正: 您請求的某些別名不會存在:{$ a_data-> ID}
這裏是我的代碼:
$request = new FacebookRequest($session, 'GET', '/me/albums?access_token='.$accessToken.'&limit=500');
$response = $request->execute();
$getUserAlbums = $response->getGraphObject();
$userAlbums = $getUserAlbums->asArray();
# logic for finding most liked user album
foreach($userAlbums['data'] as $a_data){
var_dump($a_data);
$request = new FacebookRequest($session, 'GET', '/{$a_data->id}/likes?access_token='.$accessToken.'&limit=500');
$response = $request->execute();
$getAlbumLikes = $response->getGraphObject();
$a_likes = $getAlbumLikes->asArray();
foreach($a_likes['data'] as $a_likes1){
$a_like_array[] = $a_likes1->name;
$request = new FacebookRequest($session, 'GET', '{/$a_likes1->id}?access_token='.$accessToken.'&limit=500');
$response = $request->execute();
$getUserLikes = $response->getGraphObject();
$demouser_profile1 = $getUserAlbums->asArray();
if($demouser_profile1->gender == "male")
$mtalbum++;
else
$ftalbum++;
}
$a_no_of_likes = count($a_like_array);
echo "<br>".$a_no_of_likes;
if($highest_alikes < $a_no_of_likes){
$highest_alikes = $a_no_of_likes;
$req_album = $a_data;
$album_like_array = $a_like_array;
$malbum = $mtalbum;
$falbum = $ftalbum;
}
$a_like_array = array();
$mtalbum = $ftalbum = 0;
}
,這裏是在PHP中使用的var_dump調試時我收到JSON。
object(stdClass)#14 (11){
[
"id"
] => string(15) "340014122769940" [
"from"
] => object(stdClass)#15 (2) {
[
"id"
] => string(15) "100002840667886" [
"name"
] => string(14) "Himanshu Gupta"
} [
"name"
] => string(12) "Cover Photos" [
"link"
] => string(84) "https://www.facebook.com/album.php?fbid=340014122769940&id=100002840667886&aid=66194" [
"cover_photo"
] => string(15) "340014129436606" [
"privacy"
] => string(8) "everyone" [
"count"
] => int(2) [
"type"
] => string(5) "cover" [
"created_time"
] => string(24) "2013-02-17T09:20:54+0000 " [" updated_time"
]=> string(24) "2013-11-03T06:40:57+0000" ["can_upload"
]=> bool(false)
}
如何糾正?
您需要先了解PHP如何首先運行... http://php.net/manual/en/language.types.string.php#language .types.string.parsing – CBroe 2014-11-02 15:55:54