Php 在instagram订阅源中添加“加载更多”按钮
我在一个网站上有一个instagram订阅源。另一位开发人员编写了它,我需要添加一个加载更多按钮,以便我们可以看到instagram加载的20多张照片。我不是程序员,我读过instagram API,但它让我更加困惑。我已经尝试了几种解决堆栈溢出的方法,但总是出现解析错误。我的工作代码如下,如果有人能告诉我如何添加“加载更多”按钮,甚至分页,我将不胜感激Php 在instagram订阅源中添加“加载更多”按钮,php,json,instagram,instagram-api,Php,Json,Instagram,Instagram Api,我在一个网站上有一个instagram订阅源。另一位开发人员编写了它,我需要添加一个加载更多按钮,以便我们可以看到instagram加载的20多张照片。我不是程序员,我读过instagram API,但它让我更加困惑。我已经尝试了几种解决堆栈溢出的方法,但总是出现解析错误。我的工作代码如下,如果有人能告诉我如何添加“加载更多”按钮,甚至分页,我将不胜感激 <?php function fetchData($url){ $ch = curl_init(
<?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'])) {
到
它应该可以工作。你说“不断出现解析错误”-你能告诉我们错误吗?否则我们该怎么帮你?!错误是第49行的Parse error:syntax error,意外的$end in/home/three60/public_html/core/cache/includes/elements/modsnippet/57.include.cache.php
}
if (isset($_POST['more'])) {