Hi All,
Check this out: https://dev.twitter.com/docs/auth/application-only-auth
Application-only auth allows for search-type requests to be carried out without being linked to a specific user account. Obviously canât therefore post tweets, but for sucking down a twitter feed to display on a site, itâs ideal.
You do need to create an App, but it does mean that you could use that one App to provision twitter feeds on a number of client websites (subject to the rate limit - probably best done by pulling tweets down on a schedule and storing in a database, rather than per user/pageview)
Essentially, you request a âBearer Tokenâ for your app by sending in your Consumer Key and Secret - just those 2, as opposed to the 4 required for Application & User Auth.
The returned âBearer Tokenâ doesnât expire (unless you invalidate it) so once you have it, you can store in in config files / databases etc and simply use it as an Authorization header in a standard HTTP GET request - no need for funky OAuth libraries - just PHP & curl 
As an example - hereâs how to get your bearer token:
$ch = curl_init();
//set the endpoint url
curl_setopt($ch,CURLOPT_URL, âhttps://api.twitter.com/oauth2/tokenâ);
// has to be a post
curl_setopt($ch,CURLOPT_POST, true);
$data = array();
$data[âgrant_typeâ] = âclient_credentialsâ;
curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
// hereâs where you supply the Consumer Key / Secret from your app:
$consumerKey = âxxxxxxxxxâ;
$consumerSecret = âyyyyyyyyyyyyyyyyyyyâ;
curl_setopt($ch,CURLOPT_USERPWD, $consumerKey . â:â . $consumerSecret);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
// show the result, including the bearer token (or you could parse it and stick it in a DB)
print_r($result);
Then, once you have the bearer token, to make a twitter request is simple:
//open connection
$ch = curl_init();
//set the url, including your parameters
curl_setopt($ch,CURLOPT_URL, 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=100&screen_name=twitterapi');
// add in the bearer token
$bearer = "AAAAAAAAAAAAAAAAAAAAAA.....AAAAAAAAAAAAA";
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Authorization: Bearer ' . $bearer));
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute request
$result = curl_exec($ch);
//close connection
curl_close($ch);
// Print out the JSON encoded response
print_r($result);
Hope thatâs helpful!
K