I use http://github.com/abraham/twitteroauth PHP library for reaching Twitter REST API:
<?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 can I render the Twitter userpic on the HTML page?
[EDIT]
Just do this:
The
account/verify_credentialscall returns all the user variables. So, no need to do another call.[Old Answer]
Use
users showmethod. It returns a field calledprofile_image_urlwhich you need. It’s the URL of the photo of the user.