Search code examples
twitter

Building Twitter profile image url with Twitter user id


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:
I don't want to make a api call too. I want to put user_id inside a url like

<img src="https://twitter.com/users/profile_pic?user_id=123"> Is there a url to do this?


Solution

  • With API 1.1 you can achieve this using these URLs:

    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