Instagram
niseko_hotel_kanronomori
$filemtime){
$refresh = 1;
}
}
if($refresh == 1){
$url = 'https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token='.$access_token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
$decode = json_decode($response, true);
$access_token = $decode["access_token"];
$fl = fopen($token_file_path, "w");
fwrite($fl, $access_token);
fclose($fl);
}
$refresh = 0;
if(!file_exists($photo_data_file_path)){
$refresh = 1;
}else{
$filemtime = filemtime($photo_data_file_path);
if((time()-$photo_data_refresh_time) > $filemtime){
$refresh = 1;
}
}
if($refresh == 1){
$url = "https://graph.instagram.com/me/media?fields=id,caption,permalink,media_url,thumbnail_url&access_token=".$access_token;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$photo_datas = curl_close($curl);
if(!empty($response)){
$fl = fopen($photo_data_file_path, "w");
fwrite($fl, $response);
fclose($fl);
}
} else {
$fdfp = fopen($photo_data_file_path, "r");
$response = fgets($fdfp);
fclose($fdfp);
}
$obj = json_decode($response);
echo '
';
$i = 0;
foreach($obj->data as $data){
echo '- ';
if (strpos($data->media_url, 'video') == true) {
echo '';
// foreach($data->tags as $tags){
// echo ''.$tags.'';
// }
} else {
echo '';
}
echo '
';
$i++;
if($i >= 10) break;
}
echo '
';
*/
?>