-1

我使用以下 php 代码来获取用户的 Twitter 关注者。我想将此数据导出到 csv 文件并添加过滤器以仅保存关注者超过 100 个的关注者。

<script src="http://code.jquery.com/jquery-latest.js"></script>

<?php
  $trends_url = "http://api.twitter.com/1/statuses/followers/pthiongo.json";
  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL, $trends_url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $curlout = curl_exec($ch);
  curl_close($ch);
  $response = json_decode($curlout, true);
  foreach($response as $friends){
  $thumb = $friends['profile_image_url'];
  $url = $friends['screen_name'];
  $name = $friends['name'];
  echo $friends['screen_name'];

 ?>
<a title="<?php echo $name;?>" href="http://www.twitter.com/<?php echo $url;?>"><img class="photo-img" src="<?    php echo $thumb?>" border="0" alt="" width="40" /></a>
<?php
 } 
?>
4

2 回答 2

1

首先, http://blog.gabrieleromanato.com/2012/06/jquery-get-twitter-followers-count/

然后if (followers_count > 99) 在PHP中使用一个来显示

于 2012-09-29T18:50:28.707 回答
0

以编程方式,您可以使用下面的示例请求通过 Instagram API 请求最多 100 个您自己的关注者的列表。

下面的示例请求来自 SnippetLib:

https:api.instagram.comv1users3followed-by?access_token=ACCESS-TOKEN

这条路线(来自 nbyim.com)使用分页来绕过速率限制:

from instagram.client import InstagramAPI

user_id=''
access_token = ''
client_secret = ''

api = InstagramAPI(access_token=access_token, client_secret=client_secret)

followers = []

# Get the followers list
for p in api.user_followed_by(user_id=user_id, as_generator=True, max_pages=None):
followers.extend(p[0])

# Convert from an instagram.models.User list to a list of strings
followers = [str(u).replace('User: ', '') for u in followers]

print len(followers), 'followers'
print followers

要自动化 CSV 流程,您可以使用 Crowdbabble 之类的服务:https ://www.crowdbabble.com/download-all-instagram-followers/

于 2016-09-12T19:27:31.700 回答