Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Instagram API分页器_Php_Pagination_Instagram - Fatal编程技术网

Php Instagram API分页器

Php Instagram API分页器,php,pagination,instagram,Php,Pagination,Instagram,好的,在建立了一个网站几个月之后,我已经到了最后一站,我遇到了我的第一堵无法逾越的墙 我想在这一页上添加页码。。每页24张图片,但我尝试过的一切(我尝试了几个小时!)都失败了 我讨厌厚颜无耻,但我已经没有主意了 提前谢谢,我使用的代码如下 <table cellspacing="7"><tr> <?php $count = 0; function callInstagram($url) { $ch = curl_init(); curl_setopt_array($

好的,在建立了一个网站几个月之后,我已经到了最后一站,我遇到了我的第一堵无法逾越的墙

我想在这一页上添加页码。。每页24张图片,但我尝试过的一切(我尝试了几个小时!)都失败了

我讨厌厚颜无耻,但我已经没有主意了

提前谢谢,我使用的代码如下

<table cellspacing="7"><tr>
<?php
$count = 0;
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;
}

$tag = '[tag]';
$client_id = "[id]";
$url = 'https://api.instagram.com/v1/tags/[tag]/media/recent?client_id=[id]&count=24';

$inst_stream = callInstagram($url);
$results = json_decode($inst_stream, true);

//Now parse through the $results array to display your results... 
foreach($results['data'] as $item)
   {
    $image_link = $item['images']['thumbnail']['url'];
    $author = $item['caption']['from']['username']; 
    $link = $item['link'];
    $date = $item['created_time'];
    $likes = $item['likes']['count']; 
    $comments = $item['comments']['count'];
    ?>

    <td onmouseout="this.style.opacity=1;" onmouseover="this.style.opacity=0.7;" class="content_box"><a  href="<?php echo $link; ?>" target="_blank">
    <table cellspacing="1">

    <tr><td colspan="2"><img src="<?php echo $image_link; ?>"></td></tr>
    <tr><td class="show_with_field" style="padding-left:5px; width: 110px;"><strong><?php echo $author; ?></strong>

        </td>
    <td class="discography_date" valign="bottom"><img height="8" src="images/main/like.png" width="8"> :  <?php echo $likes; ?></td></tr>

    <tr><td style="padding-left:5px; width: 110px;" class="discography_date"><?php echo date("jS F Y",$date); ?></td>

    <td class="discography_date" valign="bottom"><img height="8" src="images/main/comment.png" width="8"> :  <?php echo $comments; ?></td></tr>
    </table></a></td>

    <?php
    $count++;

    if ($count >= 6)
    {
    echo '</tr><tr>';
    $count = 0;
    }
}
?>
</td>
</tr>
</table>

如果我们查看文档,就无法定义返回的项目数量

http://instagram.com/developer/endpoints/tags/
您应该将结果保存在数据库中,然后直接在数据库中进行查询,以便在24小时前检索项目。
例如,可以使用cron作业使数据库保持最新

您想用按钮分页还是用无休止的滚动分页?Instagram在其API结果中提供了一个“下一个url”属性——您可以在页面中添加一个$\u GET参数来处理下一个url?我没有想到过无休止的滚动。没有jscript是否可能。不,不可能。必须在客户端完成。谢谢,我创建了一个数据库,从instagram和twitter获取数据。它工作得非常好,我甚至还包括了一个查找监视器,以查看用户是否删除了任何推文/图像。得到最终结果:)