Instagram分页

时间:2015-05-21 05:41:27

标签: php api

<?php
require 'db.php';

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
    ));

    //catstagram start
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

$tag = 'nypgraduation2014';
$client_id = "e4c623cb050444eeb7072e1a577da5b3";
$url = 'https://api.instagram.com/v1/tags/'.$tag.'/media/recent?client_id='.$client_id;


while (isset($url) && $url != '')
{
    $inst_stream = callInstagram($url);
    $results = json_decode($inst_stream, true);

    foreach($results['data'] as $item)
    {
        $image_link = $item['images']['standard_resolution']['url'];
        //$path_parts = pathinfo($image_link);
        // save the file name in variable
        //$image = ($path_parts['basename']);
        //copy($image_link,"photos/" .$image);
        mysql_query("INSERT INTO fypj131127cdb.instagramphoto(url) values('$image_link')");



        // copy the file to you folder

   }
   $url = $result['pagination']['next_url'];
   $image = "SELECT * FROM fypj131127cdb.instagramphoto ORDER BY ImageID ASC;";
   $img_result=mysql_query($image);
   $imageIndex = 0;

    ?>

大家好,我无法使用分页标签#nypgraduation2014显示所有Instagram图片。通过使用此代码,我不知道为什么我无法显示所有照片。因为我是php和api的新手,所以我希望你们能帮助我。谢谢!

0 个答案:

没有答案