Instagram API分页器

德克伍德

好的,所以在建设了网站几个月之后,我终于站起来了,我撞到了我的第一个不可攀登的墙。

我想在此页面上添加分页。http : //hooligansforlife.com/bands.php?info=All%20Projects&sub=Fan%20Feed每页显示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>
Jice06

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

http://instagram.com/developer/endpoints/tags/

您应该将结果保存在数据库中,然后直接在数据库中进行查询以在24之前检索项目。例如,您可以使用cron作业来使数据库保持最新。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章