Twitter OAuth PHP authentication
I am trying to create a twitter page with the Zend framework on a site I am developing where all the latest tweets, followers count and friends count of a specific user will be displayed for everyone to see.
I have gotten this far:
session_start();
$config = array(
"callbackUrl" => "http://www.site.com",
"siteUrl" => "https://api.twitter.com/oauth/request_token",
"consumerKey" => "tM3Y6mk3xlA5DHmsyOjkM",
"consumerSecret" => "QU9u6VCLlLnyBdNP6Nz0onTyKZpKb8T0jDgdKmuYhnD"
);
$consumer = new Zend_Oauth_Consumer($config);
// fetch a request token
$token = $consumer->getRequestToken();
echo $token;
// persist the token to storage
$_SESSION["TWITTER_REQUEST_TOKEN"] = serialize($token);
But everytime I open up that page, it tells me that the twitter api requires a username and password, how can I get it to stop prompting for the username and password and just display the tweets, followers count and friends count of a specific user?
If you guys know of any better ways to get this done, it would be greatly appreciated!开发者_JAVA百科
Thanx in advance!
You don't need to use OAuth to get this information. You can access the Twitter REST API for these values without any authentication, which means you can just use cURL, whicj is much easier than the entire Zend framework. You would use the call here for a specific user's tweets:
http://dev.twitter.com/doc/get/statuses/user_timeline
And this call to get the account info, like friends and followers count:
http://dev.twitter.com/doc/get/users/show
Some API calls do require authentication, but not these two.
精彩评论