开发者

How to decode Json response from facebook

I have decoded the JSON response fron facebook using $my_friends = json_decode(file_get_contents($frens));and print_r($my_friends); gives the following response :

    stdClass Object
(
    [data] =&g开发者_运维知识库t; Array
        (
            [0] => stdClass Object
                (
                    [name] => Mrinal Kumar Rai Baruah
                    [id] => 546111977
                )

            [1] => stdClass Object
                (
                    [name] => Roshan Khangembam
                    [id] => 553139665
                )

            [2] => stdClass Object
                (
                    [name] => Tarunesh Kumar Saurav
                    [id] => 620690126
                )
.........................
        )

)

I am new to JSON and m very confused . How can I iterate the above response to get the name ?


foreach($my_friends['data'] as $key => $val) {
   echo "Friend #{$key} = {$val['name']}\n";
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜