<code><?php header("Access-Control-Allow-Origin: *"); header('Content-Type: text/html; charset=UTF-8'); $url = 'https://api.instagram.com/v1/users/self/media/recent/?access_token='; $json = file_get_contents($url); $provinces = json_decode($json, true); foreach($provinces as $province){ echo $province["data"]["0"]["images"]["standard_resolution"]; } ?></code>
$json的内容大概是这样的:
<code>{"pagination":{},"meta":{"code":200},"data":[{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Normal","created_time":"1453516817","link":"https:\/\/www.instagram.com\/p\/BA3XjWMP4ye\/","likes":{"count":0},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s320x320\/e35\/12547507_218933238449715_1618422633_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s150x150\/e35\/12547507_218933238449715_1618422633_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s640x640\/sh0.08\/e35\/12547507_218933238449715_1618422633_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1168506212405185694_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}},{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Hefe","created_time":"1444533784","link":"https:\/\/www.instagram.com\/p\/8rpxxov48o\/","likes":{"count":2},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s320x320\/e35\/11910259_421481191371212_1146964092_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s150x150\/e35\/11910259_421481191371212_1146964092_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s640x640\/sh0.08\/e35\/11910259_421481191371212_1146964092_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1093151075025784616_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}}]}</code>
<code><?php header("Access-Control-Allow-Origin: *"); header('Content-Type: text/html; charset=UTF-8'); $url = 'https://api.instagram.com/v1/users/self/media/recent/?access_token='; $json = file_get_contents($url); $provinces = json_decode($json, true); foreach($provinces as $province){ echo $province["data"]["0"]["images"]["standard_resolution"]; } ?></code>
$json的内容大概是这样的:
<code>{"pagination":{},"meta":{"code":200},"data":[{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Normal","created_time":"1453516817","link":"https:\/\/www.instagram.com\/p\/BA3XjWMP4ye\/","likes":{"count":0},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s320x320\/e35\/12547507_218933238449715_1618422633_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s150x150\/e35\/12547507_218933238449715_1618422633_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpf1\/t51.2885-15\/s640x640\/sh0.08\/e35\/12547507_218933238449715_1618422633_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1168506212405185694_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}},{"attribution":null,"tags":[],"type":"image","location":null,"comments":{"count":0},"filter":"Hefe","created_time":"1444533784","link":"https:\/\/www.instagram.com\/p\/8rpxxov48o\/","likes":{"count":2},"images":{"low_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s320x320\/e35\/11910259_421481191371212_1146964092_n.jpg","width":320,"height":320},"thumbnail":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s150x150\/e35\/11910259_421481191371212_1146964092_n.jpg","width":150,"height":150},"standard_resolution":{"url":"https:\/\/scontent.cdninstagram.com\/hphotos-xpt1\/t51.2885-15\/s640x640\/sh0.08\/e35\/11910259_421481191371212_1146964092_n.jpg","width":640,"height":640}},"users_in_photo":[],"caption":null,"user_has_liked":false,"id":"1093151075025784616_2231334066","user":{"username":"misery","profile_picture":"https:\/\/scontent.cdninstagram.com\/hphotos-xta1\/t51.2885-19\/10684024_538087799681202_2023427205_a.jpg","id":"2231334066","full_name":"misery"}}]}</code>
转义而已,对自己问题的补充修改问题详情即可,不要发表在回答区域
<code><?php $json='your json value'; $obj=json_decode($json); $data=$obj->data; foreach($data as $row){ echo $row->images->standard_resolution->url."<br>"; }</code>
你只用了json_decode来解码,但是输出的时候并没有json_encode啊。 输出的应该只是一堆字符串吧? \是用来转移字符的. \/ 其实输出以后就是/