当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Instagram API Standard Object

问题描述:

I am attempting to parse the Instagram API standard object that looks like this:

 stdClass Object

(

[pagination] => stdClass Object

(

[next_url] => https://api.instagram.com/v1/users /283549787/media/recent?access_token=3036118427.1677ed0.fceea7d5e10440b691a670ddb6a97783&max_id=1059902719332635377_283549787

[next_max_id] => 1059902719332635377_283549787

)

[meta] => stdClass Object

(

[code] => 200

)

[data] => Array

(

[0] => stdClass Object

(

[attribution] =>

[tags] => Array

(

[0] => vbb

[1] => 100k

[2] => ig

)

[type] => image

[location] =>

[comments] => stdClass Object

(

[count] => 22

[data] => Array

(

[0] => stdClass Object

(

[created_time] => 1461241283

[text] => weeeelll 💥

[from] => stdClass Object

(

[username] => thewolfcult

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/12519175_228551560821189_1928102794_a.jpg

[id] => 2685463016

[full_name] => Wolf Cult

)

[id] => 17846791729091814

)

[1] => stdClass Object

(

[created_time] => 1461241621

[text] => this pic is LOL 😂😂😂

[from] => stdClass Object

(

[username] => class_y_man

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13129374_610084285824464_241975035_a.jpg

[id] => 189866780

[full_name] => Z.k

)

[id] => 17846791822091814

)

[2] => stdClass Object

(

[created_time] => 1461241649

[text] => Love it ðŸ˜

[from] => stdClass Object

(

[username] => kosmonelle

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13113731_1661552477439373_875045798_a.jpg

[id] => 2371520392

[full_name] =>

)

[id] => 17846791834091814

)

[3] => stdClass Object

(

[created_time] => 1461254879

[text] => ðŸ†ðŸ‘

[from] => stdClass Object

(

[username] => modelsandphotographers1

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/11336128_1774042986155389_99539322_a.jpg

[id] => 1418124928

[full_name] => Best Models & Photographers

)

[id] => 17846795935091814

)

)

)

[filter] => Normal

[created_time] => 1461230731

[link] => https://www.instagram.com/p/BEdQrSDytME/

[likes] => stdClass Object

(

[count] => 16672

[data] => Array

(

[0] => stdClass Object

(

[username] => jassi_bains_official

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/12327958_458252344360785_973161765_a.jpg

[id] => 2302067650

[full_name] => Jassi bains

)

[1] => stdClass Object

(

[username] => ukay.tlb527

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/11906329_960233084022564_1448528159_a.jpg

[id] => 3101669439

[full_name] => Melvin Rosetta

)

[2] => stdClass Object

(

[username] => hahmedhossam121414411

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/11906329_960233084022564_1448528159_a.jpg

[id] => 3150267725

[full_name] => Bobby Ivan

)

[3] => stdClass Object

(

[username] => somi__0

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13102392_989473131142748_1189753865_a.jpg

[id] => 2190016506

[full_name] => Somi 👸ðŸ¼ðŸ’•

)

)

)

[images] => stdClass Object

(

[low_resolution] => stdClass Object

(

[url] => https://scontent.cdninstagram.com/t51.2885-15/s320x320/e35/12918470_1000175006702614_1067887222_n.jpg?ig_cache_key=MTIzMzIxNTIxNjA0MjAzODAyMA%3D%3D.2.l

[width] => 320

[height] => 320

)

[thumbnail] => stdClass Object

(

[url] => https://scontent.cdninstagram.com/t51.2885-15/s150x150/e35/c190.0.644.644/12918387_1540009256304246_510188281_n.jpg?ig_cache_key=MTIzMzIxNTIxNjA0MjAzODAyMA%3D%3D.2.c

[width] => 150

[height] => 150

)

[standard_resolution] => stdClass Object

(

[url] => https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/12918470_1000175006702614_1067887222_n.jpg?ig_cache_key=MTIzMzIxNTIxNjA0MjAzODAyMA%3D%3D.2.l

[width] => 640

[height] => 640

)

)

[users_in_photo] => Array

(

)

[caption] => stdClass Object

(

[created_time] => 1461230731

[text] => really , thank you 🆠#ig #100k #vbb

[from] => stdClass Object

(

[username] => mattiacanfa

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13113786_488414981352515_1701597009_a.jpg

[id] => 283549787

[full_name] => Mattia Canfarotta

)

[id] => 17846789149091814

)

[user_has_liked] =>

[id] => 1233215216042038020_283549787

[user] => stdClass Object

(

[username] => mattiacanfa

[profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/s150x150/13113786_488414981352515_1701597009_a.jpg

[id] => 283549787

[full_name] => Mattia Canfarotta

)

)

)

I am trying to get standard_resolution url like this with $json_result being the object:

foreach ($json_result->data->images->standard_resolution->url as $images){

print_r($images);

}

For some reason nothing is being returned.

网友答案:

I was able to resolve because data is an array it needs to be this:

foreach ($json_result->data as $data){

foreach ($data->images->standard_resolution as $link){
echo "<img src='$link'></img>";

}
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: