TwitterOAuth Object


#1

Please help me when i implementing login with twitter on localhost then it work file but when i update this script on online server then following result occur

session_start();

require("twitter/twitteroauth.php");
require 'config/twconfig.php';

$twitteroauth = new TwitterOAuth(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET);
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken('http://abc.biz/test/fLogin/getTwitterData.php');
// Saving them into the session

$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
$_SESSION['temail']=mysql_escape_string($_POST['temail']);


echo "<pre>";
print_r($twitteroauth);	


var_dump($twitteroauth->http_code);

// 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.');
}

this is output

[http_code] => 0
[url] => https://api.twitter.com/oauth/request_token?oauth_callback=http%3A%2F%2Fugsoftware.biz%2Flittleone%2FfLogin%2FgetTwitterData.php&oauth_consumer_key=lxHk0Cno5K3z7aVrNdrSvQ&oauth_nonce=8fe746cd7d3fad13b7d820559184ce54&oauth_signature=4wAw3VZGavyM5li%2B6f61CGDSRNI%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1346680528&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/oauth/request_token?oauth_callback=http%3A%2F%2Fugsoftware.biz%2Flittleone%2FfLogin%2FgetTwitterData.php&oauth_consumer_key=lxHk0Cno5K3z7aVrNdrSvQ&oauth_nonce=8fe746cd7d3fad13b7d820559184ce54&oauth_signature=4wAw3VZGavyM5li%2B6f61CGDSRNI%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1346680528&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] => 30.775274
[namelookup_time] => 0.343329
[connect_time] => 0
[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
)

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

[consumer] => OAuthConsumer Object
    (
        [key] => lxHk0Cno5K3z7aVrNdrSvQ
        [secret] => XXXXXX
        [callback_url] => 
    )

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

)
int(0)
Something wrong happened.


#2

First: make sure never to post your consumer secret to a public forum.

If it’s not working in one environment but is in the other, usually the first thing to check is whether the server times are both set correctly and being considered correctly when computing epoch time. After that, see [node:204] for more tips.