Building Twitter profile image url with Twitter user id

前端 未结 10 1683
日久生厌
日久生厌 2020-12-04 18:06

Is there any way of building a profile image url with user id or screen name? I store user ids in database but i don\'t want to store profile image url.

edit

相关标签:
10条回答
  • 2020-12-04 18:41

    As of February 20, 2020 it would appear this is impossible. Using the API seems like the only option at the moment. For more info see my question I've opened here: Twitter profile picture images now blocked on most domains

    0 讨论(0)
  • 2020-12-04 18:42

    With version 1.1, use http://a0.twimg.com/profile_images/XXXXX/afpecvf41m8f0juql78p_normal.png where XXXXX is the User Id

    0 讨论(0)
  • 2020-12-04 18:48

    With API 1.1 you can achieve this using these URLs:

    • https://twitter.com/[screen_name]/profile_image?size=mini
    • https://twitter.com/[screen_name]/profile_image?size=normal
    • https://twitter.com/[screen_name]/profile_image?size=bigger
    • https://twitter.com/[screen_name]/profile_image?size=original

    Official twitter documentation Profile Images and Banners

    Example

    https://twitter.com/TwitterEng/profile_image?size=original
    

    will redirect to

    https://pbs.twimg.com/profile_images/875168599299637248/84CkAq6s.jpg
    
    0 讨论(0)
  • 2020-12-04 18:53

    Introducing the easiest way to get a Twitter Profile Image without using the Twitter API:

    Using http://avatars.io/

    As @AlexB, @jfred says, it doesn't work at all on mobile devices.

    And it's quite a hard way to get a redirected URL using common frameworks like PHP or JavaScript in your single page.

    Simply call http://avatars.io/twitter/ruucm at your image tag, like

    <img src="https://avatars.io/twitter/ruucm" alt="twt_profile" border="0" width="259"/>
    

    I've tested it with Angular 2+ and it works without any problem.

    0 讨论(0)
提交回复
热议问题