GoldenOwlAsia / react-native-twitter-signin

MIT License
167 stars 304 forks source link

How to get User's profile image ? #166

Open SanjanaTailor opened 3 years ago

SanjanaTailor commented 3 years ago

**https://twitter.com/[user name]/profile_image?size=original** - using this url unable to display profile image. I found that https://twitter.com/TestDem32912053/photo in browser we can see image profile pic but it is html page. so from html page again I searched for img tag where src url is https://pbs.twimg.com/profile_images/1338790043859599361/fFboACH0_400x400.jpg From the documentation API can we fetch it ? Below login data response: console.log('login Twitter Data', twitterUserLoginData);

login Twitter Data {"authToken": "1338789952348278784-u98yODHIv9Mi2AEmzud6OatmAdqU0y", "authTokenSecret": "QfvparWtQP1YSYbRkCTAhAPk7O1V8x1gueHVdEySuceNP", "email": "gdemotestt@gmail.com", "name": "TestDem32912053", "userID": "1338789952348278784", "userName": "TestDem32912053"}

I am having developer account and above data I am receiving from twitter login API . Please suggest some solution.

franznkemaka commented 3 years ago

Hi @SanjanaTailor

I will advise you to use Twitter API to fetch the user info + photo id in your own backend. It is really easy and straightforward. Plus, you can be sure that it will always work.

Steps

  1. The user logs in and you get the userID of the user
  2. Send the user id to your server

In your backend

  1. Get a bearer token from Twitter

you can find this in your Twitter API Dashboard https://developer.twitter.com/en/portal/apps/[YOUR_APP_ID]/keys it is under authentication tokens

  1. You send a request to Twitter using CURL or something

More information

Twitter official docs: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-users-profile_banner

Hope it would help