Undefined index oauth_token in line 85 twitteroauth.php


#1

I have been using my app to post tweets from users and authenticate for commenting with no problems, but now I’m getting this error and I havent changed anything. I understand why the index isn’t defined because its not returning an ‘oath_token’. Is anyone else having this problem, or does anyone have any idea why this is happening? I understand why the index isnt defined because its not returning one.


#2

Is this the library you’re using? https://github.com/abraham/twitteroauth/blob/master/twitteroauth/twitteroauth.php

Line 85 is a blank line, so maybe you have an out of date version?

It would also be helpful if you could post a snippet of your own code which is failing.


#3

yes that is the library i am using. this is the function from twitteroauth.php

/**

  • Get a request_token from Twitter
  • @returns a key/value array containing oauth_token and oauth_token_secret
    */
    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);
    // line 85
    $this->token = new OAuthConsumer($token[‘oauth_token’], $token[‘oauth_token_secret’]);
    return $token;
    }

    and from my code where I call that function

    if( !$oAuth_Token && !$oAuth_Token_Secret ){
    $nRequestToken = $oTwitter->getRequestToken($oAuth_Callback);
    $sAuthenticationUrl = $oTwitter->getAuthorizeURL($nRequestToken);
    }

#4

What is the value of $request after calling $this->oAuthRequest? There should be some error message or status code if the request failed.


#5

from twitteroauth.php

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’]);
return $token;
}

and in my code where I call that function…

if ( !$oAuth_Token && !$oAuth_Token_Secret ) {
$nRequestToken = $oTwitter->getRequestToken($oAuth_Callback);
$sAuthenticationUrl = $oTwitter->getAuthorizeURL($nRequestToken);
}


#6

echo $request;die; gives me…
Failed to validate oauth signature and token


#7

Failed to validate oauth signature and token

^ value of $request


#8

Looks like you can get more information from:

$oTwitter->http_code $oTwitter->http_info $oTwitter->url

after the getRequestToken call. print_r() dumps of each would be useful.

Also, sharing the way you’re instantiating $oTwitter would be good too.


#9

Make sure your servers clock is synced properly. A lot of times when you suddenly start getting this error it is because the servers clock has skewed a little too much.


#10

It works for me @abraham, thanks !!


#11

tNKS @abraham !! It´s Alive… Tnks @ricrangel !!


#12

Please!!! Help me!!! I have that error:


Undefined index: oauth_token
Error Type: E_NOTICE

Rendered Page: Click here to view contents able to be rendered

Source File: C:\wamp\www\Venetuits\www\twitteroauth\twitteroauth.php Line: 82

Line 77: if (!empty($oauth_callback)) {
Line 78: $parameters[‘oauth_callback’] = $oauth_callback;
Line 79: }
Line 80: $request = $this->oAuthRequest($this->requestTokenURL(), ‘POST’, $parameters);
Line 81: $token = OAuthUtil::parse_parameters($request);
Line 82: $this->token = new OAuthConsumer($token[‘oauth_token’], $token[‘oauth_token_secret’]);
Line 83: return $token;
Line 84: }
Line 85:
Line 86: /**
Line 87: * Get the authorize URL


Please!!! really!! Thanks @abraham by that resource!!! I’m Venezuelan! and i want create an app for twitter!

Sorry i dont speak english!!! i try!!!

Please Again!!!


#13

The example code for redirect didn’t work for me… Look:

Notice: Undefined index: oauth_token in C:\xampp\htdocs\scrollplus\engine\twitter\twitteroauth\twitteroauth.php on line 82

Notice: Undefined index: oauth_token_secret in C:\xampp\htdocs\scrollplus\engine\twitter\twitteroauth\twitteroauth.php on line 82

Notice: Undefined index: oauth_token in C:\xampp\htdocs\scrollplus\engine\twitter\redirect.php on line 15

Notice: Undefined index: oauth_token_secret in C:\xampp\htdocs\scrollplus\engine\twitter\redirect.php on line 16
Could not connect to Twitter. Refresh the page or try again later.

What happens?


#14

Searching in my code, trying to put all Twitter Object information in text, and the results is this code:

TwitterOAuth Object

(
[http_code] => 0
[url] => https://api.twitter.com:80/oauth/request_token?oauth_callback=http%3A%2F%2Flocalhost%2Fscrollplus%2F%3Fpid%3Dhome%26sid%3D115525071745957434367226719652410000186029296554381595675960766&oauth_consumer_key=FXQ33QMcMVIDdRVzemYaQ&oauth_nonce=035a2d6ef62a30dc4a86eb6778ff8868&oauth_signature=HgK3RNUhlZBnUEpyNZ6HhSzCjTo%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1334319743&oauth_version=1.0
[host] => https://api.twitter.com/1/
[timeout] => 30
[connecttimeout] => 30
[ssl_verifypeer] =>
[format] => json
[decode_json] => 1
[http_info] => Array
(
[url] => https://api.twitter.com:80/oauth/request_token?oauth_callback=http%3A%2F%2Flocalhost%2Fscrollplus%2F%3Fpid%3Dhome%26sid%3D115525071745957434367226719652410000186029296554381595675960766&oauth_consumer_key=FXQ33QMcMVIDdRVzemYaQ&oauth_nonce=035a2d6ef62a30dc4a86eb6778ff8868&oauth_signature=HgK3RNUhlZBnUEpyNZ6HhSzCjTo%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1334319743&oauth_version=1.0
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.172
[namelookup_time] => 0
[connect_time] => 0.187
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
(
)

        [redirect_url] => 
    )

[useragent] => TwitterOAuth v0.2.0-beta2
[sha1_method] => OAuthSignatureMethod_HMAC_SHA1 Object
    (
    )

[consumer] => OAuthConsumer Object
    (
        [key] => FXQ33QMcMVIDdRVzemYaQ
        [secret] => xxxxxxx
        [callback_url] => 
    )

[token] => OAuthConsumer Object
    (
        [key] => 
        [secret] => 
        [callback_url] => 
    )

)

¿Could you help me?


#15

Please be more careful when posting that you don’t include your consumer secret.

Have you looked at [node:204]? For starters, I recommend getting your library to send OAuth via HTTP headers instead of query string.


#16

Thanks in advice!

About your question, i will look the link later, but my question is related about the example page… If i can find the solution, i will say you soon…


#17

What do you get if you add var_dump($resposne); just before return $response; in the http function in twitteroauth.php?


#18

The problem is that there is an error in the request so you don’t get oauth_token_secret in the respond from Twitter.


#19

The problem is that there is an error in the request so you don’t get oauth_token_secret in the respond from Twitter. Check out the solution here


#20

i get this
Could not connect to Twitter. Refresh the page or try again later.