function launchInstagram($terminoBuscar) { $codea = '3106448811.1677ed0.02f5e21af36e48719aac3932ffd35a68'; /*hace el llamado a instagram*/ $userarroa = $terminoBuscar; $userarroa = strtolower($userarroa); $client_id = "ab3366d4402245ac9da6ccc519c62a98"; $url = 'https://api.instagram.com/v1/users/search?q=' . $userarroa . '&access_token=' . $codea . '&count=10'; $inst_stream = callInstagram($url); $results = json_decode($inst_stream, true); /*Recorre la información de instagram*/ $dataR = $results['data']; $armaUsuario = json_encode($dataR); $fp = fopen($_SERVER["DOCUMENT_ROOT"] . '/publication/search/results/resultInstagram.json', 'w'); fwrite($fp, $armaUsuario); fclose($fp); }
//print_r($codea); // Get recently tagged media function callInstagram($url) { $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 2)); $result = curl_exec($ch); curl_close($ch); return $result; } $userarroa = 'mentedecadente'; $userarroa = strtolower($userarroa); $client_id = "ab3366d4402245ac9da6ccc519c62a98"; //$urlCount = 'https://api.instagram.com/v1/tags/'.$tag.'?access_token='.$codea; $url = 'https://api.instagram.com/v1/users/search?q=' . $userarroa . '&access_token=' . $codea; $inst_stream = callInstagram($url); //$inst_streamC = callInstagram($urlCount); $results = json_decode($inst_stream, true); //print_r($results['data']); //$resultsCount = json_decode($inst_streamC, true); //printVar($resultsCount['data']['media_count']); //$contadorTotal=$resultsCount['data']['media_count']; /*Recorre la información de instagram*/ $dataR = $results['data']; //print_r($dataR); $armaUsuario = json_encode($dataR); var_dump($armaUsuario); die; /*Guarda conteo de instagram*/ //$campos['cantidad']=$contadorTotal; //$conteoG=guardaTweet::guardaConteoInsta($campos);
$insHash = array("link" => (string) $link, 'fechaCreacion' => $fcreacion, "imgUrl" => (string) $imgUrl, "type" => (string) $type, "texto" => (string) $texto, "cantidadComentarios" => (string) $cantidadComentarios, "likesCount" => (string) $likesUrl, "username" => (string) $username, "userimg" => (string) $userimg, "idUsuarioIng" => (string) $idUsuarioIng, "displayName" => (string) $displayName, "fecha" => date('Y-m-d H:m:s'), "fechaM" => $fechaMongoG); $hashC->insert($insHash); } echo '---------------------------------------'; //$guardarInsta = guardaTweet::guardaInstagram($campos); sleep(1); } while ($i <= $repeticiones) { if (isset($paginationN)) { $urlN = 'https://api.instagram.com/v1/tags/' . $tag . '/media/recent?access_token=' . $codea . '&max_id=' . $paginationN; $paginado = $paginationN; } else { $urlN = 'https://api.instagram.com/v1/tags/' . $tag . '/media/recent?access_token=' . $codea . '&max_id=' . $pagination; $paginado = $pagination; } $inst_streamN = callInstagram($urlN); $resultsN = json_decode($inst_streamN, true); $paginationN = $resultsN['pagination']['next_max_id']; echo '<pre>'; print_r($paginationN); echo '</pre>'; /*Recorre la información de instagram*/ $dataRN = $resultsN['data']; //printVar($dataR); $conteoResultadoN = count($dataRN); for ($i = 0; $i < $conteoResultadoN; $i++) { $imgUrl = $dataRN[$i]['images']['standard_resolution']['url']; $fcreacion = date('Y-m-d H:i:s', $dataRN[$i]['created_time']); $link = $dataRN[$i]['link']; $type = $dataRN[$i]['type']; //$link=$dataRN[$i]['link'];