I am working on a grid script with OAuth instead of Basic Auth and I'm stuck. I am currently working on authentication, but I cannot get this to work. This code:
<?php include 'config.php'; include 'twitteroauth/twitteroauth.php'; // Use config.php credentials $conn = new TwitterOAuth(CONSUMER_KEY,CONSUMER_SECRET); // Use application 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 do this at 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 inaccessible, Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error . Is anyone familiar with this problem? I followed the documentation as much as I could, but since I'm a complete rookie, I'm sure I made some kind of stupid mistake.
Also, the next question is: as soon as I get the script authorization through this process, what will be my next step in terms of capturing xml friends feed? Can I just cURL him like before?
EDIT: source getAccessToken(); 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; }
And yes, config.php is correct.
php oauth twitter
Andy
source share