拉推特个人资料图片

HP.*_*HP. 20 html javascript php api twitter

有没有快速的方法来在PHP或Javascript中提取twitter个人资料图片?我需要获取完整图像的网址(不是头像大小).谢谢.任何代码示例都很好.

abr*_*ham 46

推特 具有 有一个很好的简单网址.

https://api.twitter.com/1/users/profile_image/abraham

它有像"?size = larger"这样的尺寸选项

您可以在鲜为人知的Twitter和TwitterAPI提示和技巧上阅读更多相关信息.

Twitter现在有文档作为GET用户/ profile_image /:screen_name.

更新:已从API的v1.1中删除对此方法的支持.今后推荐的做法是在您的服务/应用程序中本地GET/users/show和缓存profile_image_url.


Ada*_* V. 12

function get_big_profile_image($username, $size = '') {
  $api_call = 'http://twitter.com/users/show/'.$username.'.json';
  $results = json_decode(file_get_contents($api_call));
  return str_replace('_normal', $size, $results->profile_image_url);
}
Run Code Online (Sandbox Code Playgroud)

get_big_profile_image('bobsaget','_ bigger')应该返回一个大头像:http://a1.twimg.com/profile_images/330305510/n229938150541_9850_bigger.jpg

get_big_profile_image('bobsaget')应该返回一个更大的图像:http://a1.twimg.com/profile_images/330305510/n229938150541_9850.jpg


tex*_*ex5 5

以前的回答者提供了我想要链接到原始的twitter api doc页面的正确答案,所以你知道它实际上是一种正式的做事方式:

你需要指定 ?size=

  • 更大 - 73px乘73px
  • 正常 - 48px乘48px
  • 迷你 - 24px乘24px
http://api.twitter.com/1/users/profile_image/twitter.json?size=bigger
http://api.twitter.com/1/users/profile_image/twitter.json?size=normal
Run Code Online (Sandbox Code Playgroud)

http://dev.twitter.com/doc/get/users/profile_image/:screen_name


小智 5

如果这是现在已知的事情,请道歉,但我在搜索过程中没有看到它记录在案,包括官方的Twitter文档.

您可以添加?size = original作为参数,该参数将返回用户的原始上传图像.

所以: http://api.twitter.com/1/users/profile_image/twitter.json?size=original