开发者

Fql returning array.. but i need an object

开发者 https://www.devze.com 2023-02-21 02:23 出处:网络
I\'m using this code to get list of friends. $params = arra开发者_运维问答y( \'method\' => \'fql.query\',

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消