簡體   English   中英

PHP的Instagram的API沒有得到所有的追隨者

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM