开发者

getting twitter username with access token

开发者 https://www.devze.com 2023-03-08 15:39 出处:网络
I\'ve a php application and successfully create a function to save access tokens and secrets in the database. (It\'s about sending specific content to their profile)

I've a php application and successfully create a function to save access tokens and secrets in the database. (It's about sending specific content to their profile)

I want to show them which twitter account they linked to my application. How can I get their twitter user wit开发者_StackOverflow中文版h access token?

Thanks for help.


When you get the access token Twitter also returns a screen_name and user_id variables. You can use those instead of making an additional request to GET account/verify_credentials


Use this instead:

$credentials = $connection->get('account/verify_credentials')

and then to get username, name, and location-

$name = $credentials->name;

$username = $credentials->screen_name;

$location = $credentials->location;
0

精彩评论

暂无评论...
验证码 换一张
取 消