开发者

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.

fetching data from json using php?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜