views:

67

answers:

2

Hi am trying to post tweets using oauth (PHP)

i created the application in my twitter account ,

i executed some open source script but that produce the below error,

Notice: Undefined index: oauth_token_secret in

How to fix this issue

my snippet

require_once('twitterOAuth/twitterOAuth.php');
require_once('twitterOAuth/OAuth.php');


$consumer_key='q3fsdfsdfsdw';
$consumer_secret='rfsdfsdfsdfsdfdsfsdL';
$request_token='http://twitter.com/oauth/request_token';
$request_token_secret='5454545';
$oauth = new TwitterOAuth($consumer_key, $consumer_secret,
$request_token, $request_token_secret);

// Ask Twitter for an access token (and an access token secret)
$request = $oauth->getAccessToken();

$access_token = $request['amp;oauth_token'];
$access_token_secret = $request['oauth_token_secret'];=======> HERE AM GETTING TROUBLE

function getAccessToken($token = NULL, $pin = NULL)
{
    if ($pin)
        $r = $this->oAuthRequest($this->accessTokenURL(),
            array("oauth_verifier" => $pin));
    else
        $r = $this->oAuthRequest($this->accessTokenURL());

    $token = $this->oAuthParseResponse($r);
    $this->token = new OAuthConsumer($token['oauth_token'],
        $token['oauth_token_secret']);

    return $token;
}

My complete Error Here

Notice: Undefined index: oauth_token_secret in E:\wamp\www\source\oauth\twitterOAuth\twitteroauth.php on line 118

Notice: Undefined index: oauth_token_secret in E:\wamp\www\source\oauth\bharani.php on line 18
A: 

It just a Notice.

You didn't defined that array index or something. Paste your full error and the lines around where php writes this notice.

Another way: You can disable with this code:

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

http://www.php.net/manual/en/function.error-reporting.php

Roland Soós
plz chk my update
Bharanikumar
plz update solution
Bharanikumar
I think you don't get oauth_token_secret in the respond from Twitter. Check out john misoskian suggestions, maybe some extensions isn't installed in your php or maybe twitter give back some error info for your request, which you can get from your twitter class.
Roland Soós
Try to print_r($oauth); after this call: $oauth->getAccessToken(); Maybe you will see some errors in the twitter respond.
Roland Soós
You can also try var_dump($oauth->http_code); to see which response code twitter is returning. http://dev.twitter.com/pages/responses_errors
abraham
A: 

Please check php companents:

  • Curl SSL
  • Open SSL
  • hash_hmac
john misoskian