i want to integrate login using twitter api on my site i use lots of code but it wont works.
<?php
session_start();
require(“twitteroauth.php”);
// The TwitterOAuth instance
$consumerkey = “XXX”;
$consumersecret = “XXXX”;
// The TwitterOAuth instance
$twitteroauth = new TwitterOAuth($consumerkey, $consumersecret);
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken(‘http://BW-E1.sumasoft.net/twitter/auth.php’);
// Saving them into the session
$_SESSION[‘oauth_token’] = $request_token[‘oauth_token’];
$_SESSION[‘oauth_token_secret’] = $request_token[‘oauth_token_secret’];
// If everything goes well…
if($twitteroauth->http_code==200){
// Let’s generate the URL and redirect
$url = $twitteroauth->getAuthorizeURL($request_token[‘oauth_token’]);
header('Location: '. $url);
} else {
// It’s a bad idea to kill the script, but we’ve got to know when there’s an error.
die(‘Something wrong happened.’);
}
?>
in this script it does not return to callback url after login which i write in my Application (it stay there only)
2)
<?php
session_start();
echo "Twitter oAuth Application by 1stwebdesigner | Login to your Twitter Account";
include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
include 'lib/secret.php';
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$oauth_token = $_GET['oauth_token'];
if($oauth_token == '')
{
$url = $twitterObj->getAuthorizationUrl();
echo $url;
echo "
";
}
else
{
$twitterObj->setToken($_GET['oauth_token']);
$token = $twitterObj->getAccessToken();
$twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);
$_SESSION['ot'] = $token->oauth_token;
$_SESSION['ots'] = $token->oauth_token_secret;
$twitterInfo= $twitterObj->get_accountVerify_credentials();
$twitterInfo->response;
$username = $twitterInfo->screen_name;
$profilepic = $twitterInfo->profile_image_url;
include 'update.php';
}
if(isset($_POST['submit']))
{
$msg = $_REQUEST['tweet'];
$twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);
$update_status = $twitterObj->post_statusesUpdate(array('status' => $msg));
$temp = $update_status->response;
echo "
Updated your Timeline Successfully .
";
}
echo "
";
?>
in this code it does not show oauth_token in passed url so cant go further
PLEASE help me! :(