在instagram订阅源中添加“加载更多”按钮


Add a Load More button to an instagram feed

我在一个网站上有一个可用的instagram提要。另一位开发者写了它,我需要添加一个加载更多按钮,这样我们就可以在instagram上看到20多张加载的照片。我不是程序员,我读过instagram API,但它让我更加困惑。我已经尝试了几种关于堆栈溢出的解决方案,但不断出现解析错误。我的工作代码如下,如果有人能告诉我如何添加"加载更多"按钮,甚至分页,我将不胜感激

    <?php
       function fetchData($url){
         $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 20);
        $result = curl_exec($ch);
        curl_close($ch); 
        return $result;
      }
  $client_id = "XXXXClientIDXXXX";
  $tag = $modx->getObject('modResource',22);
 $tagValue = $tag->getTVValue('photo-feed-hash');
 $url = 'https://api.instagram.com/v1/tags/'.$tagValue.'/media/recent?  client_id='.$client_id;
$result = fetchData($url);

$result = json_decode($result);
foreach ($result->data as $post) {
    echo '
    <div class="photo-tile '.$post->user->username.'">
        <a class="lightbox" rel="gallery1" title="'.$post->user->username.' - '.$post->caption->text.'" href="'.$post->images->standard_resolution->url.'">
            <img src="'.$post->images->low_resolution->url.'" />
            <span>'.$post->user->username.'</span>
        </a>
    </div>';
   if (isset($_POST['more'])) {
     $result = fetchData("https://api.instagram.com/v1/tags/apple/media/recent/?access_token=964985675.5b9e1e6.aede14d1d33e4cc8b11662af423b9762&count=15&max_id=1387332905573");
$result = json_decode($result);
foreach ($result->data as $post) {
    echo '<div class="instagram-unit"><p class="instagram-desc">'.htmlentities($post->caption->text).'</p>
    <a class="instagram-link fancybox-media" rel="gallery" title="'.htmlentities($post->caption->text).'" href="'.$post->link.'">
    <img class="instagram-img" src="'.$post->images->thumbnail->url.'"/></a>
    </div>';
}
}
 ?>
  <form method="post" action="">
  <input class="submit" type="submit" name="more" />

您有4个开头大括号({),但只有3个结尾大括号(})。这就是你得到解析错误的原因。

更改

if (isset($_POST['more'])) {

}
if (isset($_POST['more'])) {

它应该起作用。