Answer the question
In order to leave comments, you need to log in
How to cache request or images from Instagram API?
I make a request by tags
$hashtags = array( "тег1", "тег2", "тег3", "тег4");
for($i=0; $i<count($hashtags); $i++)
{
// make request
$ch = curl_init();
if($hashtags[$i] == 'тег1'){
curl_setopt($ch, CURLOPT_URL, "https://api.instagram.com/v1/tags/{$hashtags[$i]}/media/recent?access_token=MyTOKEN&count=2");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
}elseif($hashtags[$i] == 'тег2'){
curl_setopt($ch, CURLOPT_URL, "https://api.instagram.com/v1/tags/{$hashtags[$i]}/media/recent?access_token=MyTOKEN&count=3");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
}else{
curl_setopt($ch, CURLOPT_URL, "https://api.instagram.com/v1/tags/{$hashtags[$i]}/media/recent?access_token=MyTOKEN&count=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
}
// convert response
$jdata = json_decode($output);
//Вывод
for($j=0; $j<count($jdata->data); $j++){
if(!empty($jobj->data[$j]->images->standard_resolution->url)){
echo ' <img src="'. $jdata->data[$j]->images->standard_resolution->url .'"> '
}
}
}
Answer the question
In order to leave comments, you need to log in
An extremely strange question, if you cache the api responses, during the cache time you will not access the instagram. According to your version, you will request those 10 requests every 5 hours.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question