This code should only unfollow users who are not following back, but it unfollows SOME followers, cannot figure out why.
$oTwitter = new TwitterOAuth (...)
$aFo
If your of followers is greater than 5000 then $aFollowers = $oTwitter->get('followers/ids');
will only return the first 5000 ids. In what order? Twitter does not guarantee any order, so we'll just assume random.
If the following check $isFollowing = in_array( $iFollowing, $aFollowers );
, the person $iFollowing
may or may not be in the list $aFollowers
depending on how Twitter returned the followers to you. If the person is in the first 5000, then this will work, if they're outside the first 5000 then the check will fail, even if the person is legitimately following you.
You'll need to pull all your followers via cursors. Check out the doc on cursors / pages - will help you out a bit. Basically you need to do this.
$aFollowers = array();
$cursor = -1;
do {
$follows = $oTwitter->get('followers/ids?cursor=' . $cursor);
$aFollowers = array_merge($follows->ids, $aFollowers);
$cursor = $follows->next_cursor;
} while ($cursor > 0);