Fql returning array.. but i need an object
I'm using this code to get list of friends.
$params = arra开发者_运维问答y(
'method' => 'fql.query',
'query' => "SELECT uid FROM user WHERE uid = me()
OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())",
);
$result = $facebook->api($params);
now i'm displaying the picture of user as
echo "<img src='http://graph.facebook.com/".$result[0]."/picture'>";
but it is still returning the result as an array like this: http://graph.facebook.com/array/picture I need the uid at that place where it is showing array. Help please. its really important
print_r ($result[0]);
gives the following output----
Array ( [uid] => XXXXXXXX )
This is 2-D array no need to convert it into object you can still access it
To access uid you have to do something like this
echo $result[0]['uid'];
Hence you code will become
echo "<img src='http://graph.facebook.com/".$result[0]['uid']."/picture'>";
If you still want object instead of array you can do type cast.
$result_obj= (object) $result[0];
echo $result_obj->uid;
精彩评论