fetching data from json using php?
I have a Json data retrieved from facebook using graph api, now i am going to parse that data, i decoded that json
$decodedjson= json_decode($jsondata);
after that i开发者_JAVA技巧 got data in following format.
i write
$id= $decodedjson->message_id;
to get the id, the attachment is an other object, please tell me how can i access the attachment, media, href, alt and the video , display_url and so on, name etc
Thanks
Just like any object -
$vid=($decodedjson[2])->attachment->media[0];
$alt=$vid->alt;
Edit: Noticed the [2]=>...
at the top of your var_dump
json_decode - convert json format to php array You should access it as array
$id= $decodedjson[0]['message_id'];
$attachment= $decodedjson[0]['attachment']['media'];//an array
$video= $decodedjson[0]['media'][0]['video']['owner'];
精彩评论