Home >Backend Development >PHP Tutorial >How to Retrieve a User's Twitter Timeline Using PHP and API v1.1?
Simplest PHP Example for Retrieving User_Timeline with Twitter API Version 1.1
Due to the retirement of Twitter API 1.0 on June 11th, 2013, the original script mentioned is no longer functional. This guide provides an updated approach to retrieving recent user statuses with minimal coding effort.
Prerequisites:
PHP Code
To simplify the task, a PHP class is provided:
require_once('TwitterAPIExchange.php'); // Replace these values with your application's tokens $settings = [ 'oauth_access_token' => 'YOUR_ACCESS_TOKEN', 'oauth_access_token_secret' => 'YOUR_ACCESS_TOKEN_SECRET', 'consumer_key' => 'YOUR_CONSUMER_KEY', 'consumer_secret' => 'YOUR_CONSUMER_SECRET' ]; // Define the API endpoint and request method $url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; $requestMethod = 'GET'; // Create the TwitterAPIExchange instance $twitter = new TwitterAPIExchange($settings); // Build the request and perform it echo $twitter->buildOauth($url, $requestMethod)->performRequest();
Usage:
The above is the detailed content of How to Retrieve a User's Twitter Timeline Using PHP and API v1.1?. For more information, please follow other related articles on the PHP Chinese website!