有一张桌子,我正在努力。试图让它从$json
变量中抓取所有用户,然后添加?offset=25
然而,当我点击它并更改URL时,里面的实际数据不会继续。
<?PHP
$offset = 0;
//Stream Follow Json
$json = json_decode(file_get_contents("https://api.twitch.tv/kraken/channels/greatbritishbg/follows?limit=25&offset". $offset));
$i = 0;
//check if the starting row variable was passed in the URL or not
//this part goes after the checking of the $_GET var
$num= 25;
// Creating an object
$json->follows;
if($num>0)
{
echo "<table border=2>";
echo "<tr><td>Username</td><td>Follow Date</td></tr>";
foreach($json->follows as $follow) {
$i++;
echo "<tr>";
echo "<td><a href='" . $follow->user->_links->self . "'>" . $follow->user->name . " (".$i. ")</td>";
echo "<td>" . $follow->user->created_at . "</td>";
echo "</tr>";
}//for
echo"</table>";
}
//now this is the link..
echo '<a href="'.$_SERVER['PHP_SELF'].'?limit=25&offset='.($offset+25).'">Next</a>';
$prev = $offset - 25;
//only print a "Previous" link if a "Next" was clicked
if ($prev >= 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?limit=25&offset='.$prev.'">Previous</a>';
?>
如果我将?limit=25&offset=50
添加到https://api.twitch.tv/kraken/channels/greatbritishbg/follows,那么它将显示数据库中的下一组用户。
但如果我在网站上添加?limit=25&offset=50
到我的网址,那就没有。
任何帮助将不胜感激
答案 0 :(得分:0)
在您的代码中,
limit=25". $offset
变为
limit=250
你需要
limit=25&offset=". $offset