Some of the aliases you requested do not exist: {$

2019-09-21 19:12发布

While I am developing a facebook application, the following error is coming which I am unable to correct: Some of the aliases you requested do not exist: {$a_data->id}

Here is my code:

$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;
             }

and here is the json which I am getting when debugging using var_dump in php.

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)
}

How to correct this??

1条回答
做自己的国王
2楼-- · 2019-09-21 19:43

It seems like you're literally sending Facebook {$a_data->id} instead of the id you actually meant to ask for - fix your code to send the ID instead of that string

If {$....} is interpreted as an escape sequence, fixing this could be as easy as changing the single quotes to double quotes

查看更多
登录 后发表回答