Authenticating with oauth/twitter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
capypara
Forum Newbie
Posts: 1
Joined: Mon Aug 15, 2011 5:19 am

Authenticating with oauth/twitter

Post by capypara »

hi guys.

i am trying to authenticate users using Twitteroauth, but i have a problem. in the line

$request_token = $twitteroauth->getRequestToken('my url here');

i get notices (Notice: Undefined index: oauth_token) when my i type my url inside the brackets. however if i leave the field blank like this

$request_token = $twitteroauth->getRequestToken();

i get redirected to twitters site as expected and there are no errors, just that i dont get redirected after authentication.

Code: Select all

session_start();
require('twitter-async/twitteroauth.php');

// The TwitterOAuth instance
$twitteroauth = new TwitterOAuth("jjUgFzcdCRkR6EB5Ka11w", "9M1g76mvNglctSZJu65ApDonpv56FX5gBZkw3T0DQA");
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken('my url here');

// Saving them into the session
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
this are the notices i got
Notice: Undefined index: oauth_token in C:\xampp\htdocs\capypara chat\twitter-async\twitteroauth.php on line 80
Notice: Undefined index: oauth_token_secret in C:\xampp\htdocs\capypara chat\twitter-async\twitteroauth.php on line 80

here's the related code in the twitteroauth.php file

Code: Select all

  function getRequestToken($oauth_callback = NULL) {
    $parameters = array();
    if (!empty($oauth_callback)) {
      $parameters['oauth_callback'] = $oauth_callback;
    }
    $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
    $token = OAuthUtil::parse_parameters($request);
    $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); //this is line 80
    return $token;
  }
can anyone help? thanks for looking.
Post Reply