简体   繁体   中英

How to get JSON data from foursquare venue tips api url and make it in HTML

I am new to php and json. My goal is here to get specific venue tips from foursquare api and display them as HTML content. I can get tips that i wanted as json however i have problems to decode them and display them as HTML

Here what i tried;

$json = file_get_contents('https://api.foursquare.com/v2/venues/53a03c0a498ebaba35742592/tips?sort=recent&oauth_token=TOKEN_HERE');

$data = json_decode($json,true);

$Geonames = $data['items'][0];

echo "<pre>";

print_r($Geonames);

exit;

I did not get anything. Then i tried another way to get them. I could get response from foursqure i could get tips but i cannot decode them. I just need text , canonicalUrl , firstname , lastname and photo data from api response.

Need your helps can`t wait to see them. Thanks

Check the structure of decoded data first. You receive complex array where items are in respons and then tips. So if you want to get them, you have to call to

$data['response']['tips']['items'][0]

Use print_r() or var_dump() on received data first and analyze the structure before you ask again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM