[英]php instagram api not getting all the followers
我创建了一个php脚本,它将使用instagram用户的用户标识,并将废弃该用户的所有关注者。 下面是脚本。 问题是当我尝试获取用户的总关注者列表时,该用户说比我的脚本多1或2百万个关注者,并在错误PHP Warning: in_array() expects parameter 2 to be array, null given in filename.php on line LINE NO
错误的6万个用户名后崩溃PHP Warning: in_array() expects parameter 2 to be array, null given in filename.php on line LINE NO
<?php
require '../src/Instagram.php';
/////// CONFIG ///////
$username = 'USERNAME';
$password = 'PASSWORD';
$debug = false;
$i = new Instagram($username, $password, $debug);
$myfile = fopen("file.txt", "w") or die("Unable to open file");
try {
$i->login();
$var = $i->getUserFollowers("432464344");
do {
$results = $var['users'];
foreach($results as $result) {
$username = $result['username'];
$username = $username . "\n";
fwrite($myfile, $username);
}
if (in_array('next_max_id', $var)) { // <-- HERE ERROR
$next_max_id = $var['next_max_id'];
} else {
break;
}
$var = $i->getUserFollowers("432464344", $next_max_id);
} while (1);
} catch (InstagramException $e) {
$e->getMessage();
fclose($myfile);
exit();
}
echo $count;
fclose($myfile);
谢谢并恭祝安康,
问题必须出在getUserFollowers函数上( 期望参数2为数组,给定null )。 只需检查该函数可以返回null的可能性并解决。
Instagram可能阻止了您的请求并返回错误,或者系统中的系统内存使用过多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.