Hi list,
I am using abraham williams library to update twitter status using
oauth. But I am constantly getting 'session expired' error. How can I
get around this. This is my source.
index.php
<?php
session_start();
require_once 'twitteroauth/TwitterOAuth.php';
define("CONSUMER_KEY", "--------------------");
define("CONSUMER_SECRET", "---------------------------");
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $connection->getRequestToken('http://127.0.0.1/
callback.php');
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] =
$request_token['oauth_token_secret'];
$url = $connection->getAuthorizeURL($request_token);
header('Location: ' . $url);
?>
callback.php
<?php
session_start();
require_once 'twitteroauth/TwitterOAuth.php';
define("CONSUMER_KEY", "------------------");
define("CONSUMER_SECRET", "----------------------------");
if (isset($_REQUEST['oauth_token']) && $_SESSION['oauth_token'] !==
$_REQUEST['oauth_token']) {
echo 'Session expired';
echo ':';
echo $_REQUEST['oauth_token'];
echo '<<<<<->>>>';
echo $_SESSION['oauth_token'];
}
else {
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
$token_credentials = $connection->getAccessToken();
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,
$token_credentials['oauth_token'],
$token_credentials['oauth_token_secret']);
$tweetmsg = 'Hello World, I am tweeting from my own twitter app!';
$result = $connection->post('statuses/update', array('status' =>
$tweetmsg));
$httpCode = $connection->http_code;
if ($httpCode == 200) {
$resultmsg = 'Tweet Posted: '.$tweetmsg;
}
else {
$resultmsg = 'Could not post Tweet. Error: '.$httpCode.' Reason: '.
$result->error;
}
}
?>
--
You received this message because you are subscribed to the Google Groups
"OAuth" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/oauth?hl=en.