我正在重新编码我的Stream Refresher,但是如何获得这个庞大的数组列表呢?如何将它们输出到变量中?我真的不知道如何构建我的代码来获取这些数组。
这是数组:
这是我的尝试(我不知道我说实实在在做什么)
<?php
header('Content-Type: text/html; charset=UTF-8');
$con = mysqli_connect("localhost", "0", "0", '0');
$result = mysqli_query($con, "SELECT * FROM mybb0_streams");
$array_ids;
while ($row = mysqli_fetch_array($result)) {
$array_ids[] = $row['channel'];
}
$json_array = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams?channels=' . implode(',',$array_ids)), true);
foreach($json_array as $user){
if ($json_array['stream'] != NULL) {
// turn them into variables to prevent outside SQL injection
$displayname = mysqli_real_escape_string($con, $json_array[0]['channel']['name']);
$title = mysqli_real_escape_string($con, $json_array[0]['title']);
$game = mysqli_real_escape_string($con, $json_array[0]['channel']['meta_game']);
$viewers = mysqli_real_escape_string($con, $json_array['stream']['viewers']);
$preview = mysqli_real_escape_string($con, $json_array['stream']['preview']['medium']);
$followers = mysqli_real_escape_string($con, $json_array['stream']['channel']['followers']);
echo 'Display Name: $displayname | Title: $title | Game: $game | Viewers: $viewers | Followers: $followers <br />';
}
}
echo "http://api.justin.tv/api/stream/list.json?channel=" . implode(',',$array_ids);
?>