嗨亲爱的朋友,我需要你的帮助。
我们如何使用php访问Web API? 我这样做但在Client_Id上它显示我的访问令牌错误,而我的Instagram访问令牌是新的或未过期和正确
<?php
if(!empty($_GET['location'])){
$maps_url='https://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($_GET['lacation']);
$maps_json = file_get_contents($maps_url);
$maps_array=json_decode($maps_json,true);
$lat= $maps_array['result'][0]['geometry']['location']['lat'];
$lng = $maps_array['result'][0]['geometry']['location']['lng'];
$instagram_url = 'https://api.instagram.com/v1/media/search?lat='.$lat.'&lng'= .$lng. '&client_id=xxxxxxxxxxxxxxxxxx'
$instagram_json = file_get_contents($instagram_url);
$instagram_array = json_decode($instagram_json,true);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>WebApi_Learning</title>
</head>
<body>
<form action="">
<input type="text" name="location"/>
<button type="submit">Submit</button><br>
<?php
if(!empty($instagram_array)){
foreach($instagram_array['data']as $image){
echo '<img src='. $image['images']['low_resolution']['url'].'" alt="" />';
}
}
?>
</form>
</body>
</html>