Twitter API fetch profile data from given token after redirect to callback url

﹥>﹥吖頭↗ 提交于 2019-12-11 10:57:35

问题


I'm working with twitter API and I want to implement login in my site using this API.
I did the first part and I have successfully conencted to twitter and get the authorisation token and been redirect to my callback url, but I 'm stuck there right now I don't know how to fetch profile data from this token.
Authorisation page:
After redirect I get back to my callback route:
As you can see I have received an authorisation token but I don't what to do get profile's data!!
and this is where I' stuck now:

/**
     * @Route("/twitter-callback", name="front_twitter_callback")
     */
    public function twitterCallbackAction(Request $request)
    {
        $oauth_token = $request->query->get('oauth_token');// the token
    }

UPDATE:
I found a solution described here but it's not working very well, i mean I did received some info but it's the infos of the user who created the app not the connected one who who gave permission to the application to access his data.
This is what I did :

$data = $this->twitterAccesData();
        // create TwitterOAuth object
        $twitteroauth = new TwitterOAuth($data['key'], $data['secret'], $data['access_token'], $data['access_token_secret']);
        $user = $twitteroauth->get('account/verify_credentials', $data);

        die(var_dump($user)); // this always give me the same profile info no matter what user is connected!

Any help please, and thanks in advance.

来源:https://stackoverflow.com/questions/46756929/twitter-api-fetch-profile-data-from-given-token-after-redirect-to-callback-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!