I am new to twitter API and I am using the Abraham Williams PHP twitter library to oauth user and sign in.
require_once ("twitteroauth.php");
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret);
/* Get temporary credentials. */
$request_token = $connection->getRequestToken($this->callback);
/* Save temporary credentials to session. */
$this->session->set_userdata('oauth_token', $request_token['oauth_token']);
$this->session->set_userdata('oauth_token_secret', $request_token['oauth_token_secret']);
/* If last connection failed don't display authorization link. */
switch ($connection->http_code)
{
case 200:
$url = $connection->getAuthorizeURL($request_token['oauth_token'], TRUE);
header('Location: ' . $url);
break;
default:
echo 'Could not connect to Twitter. Refresh the page or try again later.';
}
But I always get an error the message “Could not connect to twitter’ and I’m not redirected to the twitter oauth page. What am I doing wrong.
I figured out the problem. I hadn’t provided with a callback url in the app settings and twitter saw this as a desktop app instead of a web app.