开发者

How to decode Json response from facebook

开发者 https://www.devze.com 2023-04-01 03:17 出处:网络
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 :

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

精彩评论

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

关注公众号