doumen9709 2015-09-07 12:32
浏览 69
已采纳

跟随者限制使用PHP到达Instagram API

Im trying to get all my information from my Instagram profile. If i got <50 followers it displays correct. My test profile has like 7 - 8 followers. My real profile has like 200 followers but the max what my code is printing is 49 when limit = 0 in my functions. When I change that limit to 25000 it prints +- 100 followers. My main question is. How do i get the correct amount of followers when the amount is > 200.

my function:

public function getUserFollower($id = 'self', $limit = 25000)
{
    $params = array();
    if ($limit > 0) {
        $params['count'] = $limit;
    }
    return $this->_makeCall('users/' . $id . '/followed-by', true, $params);
}

Im Calling my Object how I'm supposed to. It works.

$getFollowers = $instagram->getUserFollower();

Then I'm counting my amount of followers:

echo '<b>Followers:</b> '. count($getFollowers->data).'</br>';

But the limit in this case (using my real profile) is : 96

do i have to use the 'pagination' from instagram? If i need to, how should i do that?

Thanks in advance,

Armando v O

  • 写回答

1条回答 默认 最新

  • douhan8009 2015-09-08 09:48
    关注

    I fixed it now. Im doing it without the pagination class. So it's saving code. Means less server space. (Not that it's much space).

    $getFollowers = $instagram->getUserFollower()
    $iFollowers = 0;
    do{
        $iFollowers += count($getFollowers->data);
    
        if($getFollowers->pagination->next_url){
            $getFollowers = json_decode(file_get_contents($getFollowers->pagination->next_url));
        } else {
            $getFollowers = FALSE;
        }
    
    }while ($getFollowers !== FALSE);
    
    echo 'Followers: '.$iFollowers. "<br / >";
    

    Thanks for helping.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏