I'm working on making my script mesh with OAuth instead of Basic Auth, and I'm stuck. So far, I'm just working on authenticating at the moment, but I can't get that working. This code:
<?php
include 'config.php';
include 'twitteroauth/twitteroauth.php';
// Use config.php credentials
$conn = new TwitterOAuth(CONSUMER_KEY,CONSUMER_SECRET);
// Use application's registered callback URL
// And get temporary credentials using made connection
$tempCred = $conn->getRequestToken();
// Use 'Sign in with Twitter'
// for Redirect URL
$rURL = $conn->getAuthorizeURL($tempCred);
echo '<a href="'.$rURL.'">1. Click me first!</a><br />';
works just fine. However, when I make it to this step:
// Build a new TwitterOAuth connection
// Now that the app has verified credentials
$conn = new TwitterOAuth(CONSUMER_KEY,
CONSUMER_SECRET,
$_SESSION['oauth_token'],
$_SESSION['oauth_token_secret']);
// Get non-temporary credentials from Twitter
$tokenCred = $conn->getAccessToken();
echo '<a href="index.php">2. Click me next!</a><br />';
?>
I get a Page Not Available, Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error
. Is anyone familiar with this issue? I was following the documentation as closely as I could, but as I am a complete rookie I'm sure I made some stupid mistake.
Also, a follow up question: Once I do get my script authorizes via this process, what is my next step in terms of grabbing the friends feed xml
? Can I just cURL
it like before?
EDIT: The source for getAccessToken();
is as follows:
function getAccessToken($oauth_verifier = FALSE) {
$parameters = array();
if (!empty($oauth_verifier)) {
$parameters['oauth_verifier'] = $oauth_verifier;
}
$request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
$token = OAuthUtil::parse_parameters($request);
$this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
return $token;
}
Anybody? Pleaase? I've been up all night hacking at this, I need some sort of release! And yes, config.php is correct.