O
O
Oleg2015-05-03 13:00:11
PHP
Oleg, 2015-05-03 13:00:11

Autosearch and autoposting on instagram, what's wrong with that?

We need a script that will automatically search Instagram for photos with a specific #hash tag and post them to the page. I found the only example of how to implement it, so that there are no repeated postings of the same photo and auto work.

<?
//Ищем нужный хеш-тег
$hashtag = 'nikolaev';
//Подключаем id приложения
$query = array(
'client_id' => '2402ce55a602493fbbbac5ff649b01d5',
'count'	=> 30
);
$url = 'https://api.instagram.com/v1/tags/'.$hashtag.'/media/recent?'.http_build_query($query);
try {
$curl_connection = curl_init($url);
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);

//Берем данные с $data
$data = json_decode(curl_exec($curl_connection), true);
curl_close($curl_connection);

if (is_array($data)&&array_key_exists('data',$data)&&is_array($data['data'])){

foreach($data['data'] as $key=>$item){
if (array_key_exists('images',$item)){
echo ''.$item.'images''standard_resolu';
}
}

}
echo ''; print_r($data);
} catch(Exception $e) {
return $e->getMessage();
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question