views:

27

answers:

1

I use PHP Lib to support OAuth for Twitter's REST API http://github.com/abraham/twitteroauth

<?php
    session_start(); 
    require("config.php");
    require("twitteroauth/twitteroauth.php");
    if(!empty($_GET['oauth_verifier']) &&
       !empty($_SESSION['oauth_token']) &&
       !empty($_SESSION['oauth_token_secret'])
    )
    {                        
        $twitteroauth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);  
        $access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']); 
        $_SESSION['access_token'] = $access_token; 
        $user_info = $twitteroauth->get('account/verify_credentials');
        // ?...
?>

How to get the twitter userpic? Thanks!

+3  A: 

[EDIT]

Just do this:

echo '<img src="'.$user_info->profile_image_url.'"/>;

The account/verify_credentials call returns all the user variables. So, no need to do another call.

[Old Answer]

Use users show method. It returns a field called profile_image_url which you need. It's the URL of the photo of the user.

shamittomar