json_de code帮助 [英] json_decode help
本文介绍了json_de code帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试使用一些API的各种服务的,目前即时试图检索,
Vimeo上的视频数据我已经顺利拿到了文件,读取内容,但是,我不知道如何来访问返回一个以.json文件的各个部分。
基本上,我如何访问使用PHP在JSON文件中的数据
感谢
解决方案
$ file_contents =的file_get_contents(http://vimeo.com/api/v2/group/awesome/videos。 JSON),TRUE);
使用读入一个变量:
$数据= json_de code($ file_contents);
然后就可以使用访问部分:
回声$ DATA-和SEQ ID;
回声$数据 - >称号;
等。
只要使用的print_r($数据);
来查看所有可用字段
I have been trying to use some API's from various services, At the moment im trying to retrieve data about a video on vimeo,
I have successfully got the file and read the contents, however, i do not know how to access each part of the file that is returned as a .json.
Basically, how do i access the data in the json file using PHP
Thanks
解决方案
$file_contents = file_get_contents("http://vimeo.com/api/v2/group/awesome/videos.json"), true);
Read it into a variable using:
$data = json_decode($file_contents);
then you can access the parts using:
echo $data->id;
echo $data->title;
etc.
Just use print_r($data);
to see all available fields.
这篇关于json_de code帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文