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
I had the same error:
Debugging on line what the error specified:
I found this:
After i read some issue on the web and find the solution. In my code i must pass a oauth_verifier:
Hope i help someone, the problem was that For OAuth 1.0a compliance 'oauth_verifier' is required!
Resource: https://dev.twitter.com/discussions/16443#comment-36618
Apologize for bad English.
@Bharanikumar
AFAIK first you should call the function
then u will get
then do below
& then apply your code
Hope this will help you..
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 a simple but elaborate solution here.. http://errorbank.blogspot.com/2012/07/php-twitter-undefined-index.html
Please check php companents:
This issue was solved for me by setting a Callback URL in my twitter application settings. http://dev.twitter.com
In your twitter application setting "Callback URL", add any callback url, for ex:
https://dev.twitter.com/
Otherwise twitter will consider your application as desktop application and you will get error:
and your php script will give errors like:
But by setting a callback url from php script it will overwrite the default placeholder of callback url and consider your application as a web based application.