Can't Get oauth_token always empty


#1

I am trying to make twitter login with my domain, but every time, I getting error.

https://api.twitter.com/oauth/authenticate?oauth_token=
Whoa there!
There is no request token for this page. That’s the special key we need from applications asking to use your Twitter account. Please go back to the site or application that sent you here and try again; it was probably just a mistake.

Can u guide me Why it’s not working… Does my domain blacklist by twitter api ? Because when i test my code with another domain its working :frowning:
what should i do ?


#2

How are you generating the request token? Are you using a third-party library? Did you register an application with Twitter and get a consumer key/secret?


#3

yes register an application with Twitter and get a consumer key/secret
Code works on another domain good but when i try it on my main domain not working oauth_token= missing

my login php code is here

<?php
require("twiOauth/twitteroauth.php");
require 'twiOauth/twconfig.php';
session_start();
$twitteroauth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $twitteroauth->getRequestToken('http://mydomain.com/twit/getTwitterData.php');
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
$url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
header('Location: ' . $url);
?>

// getTwitterData.php

<?php
require("twiOauth/twitteroauth.php");
require 'twiOauth/twconfig.php';
session_start();
if (!empty($_GET['oauth_verifier']) && !empty($_SESSION['oauth_token']) && !empty($_SESSION['oauth_token_secret'])) {
    // We've got everything we need
    $twitteroauth = new TwitterOAuth(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
// Let's request the access token
    $access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']);
// Save it in a session var
    $_SESSION['access_token'] = $access_token;
	}
?>

i am using this library

<?php

/*
 * Abraham Williams (abraham@abrah.am) http://abrah.am
 *
 * The first PHP Library to support OAuth for Twitter's REST API.
 */

/* Load OAuth lib. You can find it at http://oauth.net */
require_once('OAuth.php');

/**
 * Twitter OAuth class
 */
class TwitterOAuth {
  /* Contains the last HTTP status code returned. */
  public $http_code;
  /* Contains the last API call. */
  public $url;
  /* Set up the API root URL. */
  public $host = "https://api.twitter.com/1.1/";
  /* Set timeout default. */
  public $timeout = 30;
  /* Set connect timeout. */
  public $connecttimeout = 30; 
  /* Verify SSL Cert. */
  public $ssl_verifypeer = FALSE;
  /* Respons format. */
  public $format = 'json';
  /* Decode returned json data. */
  public $decode_json = TRUE;
  /* Contains the last HTTP headers returned. */
  public $http_info;
  /* Set the useragnet. */
  public $useragent = 'TwitterOAuth v0.2.0-beta2';
  /* Immediately retry the API call if the response was not successful. */
  //public $retry = TRUE;

#4

finaly i found the problem this code not works on hostgator server
i check it on dreamhost it works.so problem is server side
how i fix it ?

I have hostgator server baby plan.


#5

I’m not familiar with hostgator. Maybe they have a support forum you can get help in.


#6

i submitted support ticket :worried: lets see what’s error. i trying since 4 hour but not working.