我从此PHP开始,并且编写了一个使我出错的代码:
第31行的C:\ xampp \ htdocs \ vs api3.php中未定义的偏移量:0。
我需要从其他渠道下载数据。频道ID分别存储在txt中。我想要的是让您阅读存储在txt文件中的ID,然后下载该ID的订阅者的数据。
如果可以帮助我下载88x88频道的图片,那就走一步……发现它相当可观,节省了时间。
<body>
<?php
function multiexplode ($delimiters,$string) {
$ready = str_replace($delimiters, $delimiters[0], $string);
$launch = explode($delimiters[0], $ready);
return $launch;
}
$text = file_get_contents("C:/topvs2.txt");
$exploded = multiexplode(array(" (","#1 ",") - #2 ",") - #3 ",") - #4 ",") - #5 ",") - #6 ",") - #7 ",") - #8 ",") - #9 ",") - #10 ",") - #11 ",") - #12 ",") - #13 ",") - #14 ",") - #15 ",") - #16 ",") - #17 ",") - #18 ",") - #19 ",") - #20 "),$text);
$id1= file_get_contents("C:/$exploded[3].txt");
$exploded1 = multiexplode(array("|"),$id1);
$channel_id = $exploded1[1];
$api_key = "My_API";
$api_response =
file_get_contents('https://www.googleapis.com/youtube/v3/channels?part=statistics&id='.$channel_id.'&fields=items/statistics/subscriberCount&key='.$api_key);
$api_response_decoded = json_decode($api_response, true);
echo $api_response_decoded['items'][0]['statistics']['subscriberCount'];
?>
</body>
我需要能够从文本文件中读取ID,并将其放在变量$ channel_id中。 Whithout未确定的偏移量。 预先感谢。