Ok, i fell anxious about OAuth
When i try to get connected thru OAuth, i get a
"Failed OAuth Request: Unknown request token ""
answer, whatever i do.
I'm using a web Apache server on a Linux computer. All is stored in /var/www/telldir
In order to be quiet, i did a chown www-data:www-data on all files, and a chmod 700
I installed PEAR without problems:
sudo pear install --alldeps --force HTTP_OAuth channel://pear.php.net/HTTP_OAuth-0.2.3
sudo apt-get install php-pear php5-dev make
I use the same files than Manticus in previous threads, i read all the forums about OAuth, i even get trhu TweeterAuth stuff in order to try and i do not see what the problem is:
common.php
Code: Select all
<?php
header('Content-Type: text/html; charset=utf-8');
session_start();
require_once 'HTTP/OAuth/Consumer.php';
define('KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX');
define('SECRET', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX');
define('TOKEN', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
define('TOKEN_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxx');
define('URL', 'https://api.telldus.com'); //https should be used in production!
define('REQUEST_TOKEN', constant('URL').'/oauth/requestToken');
define('AUTHORIZE_TOKEN', constant('URL').'/oauth/authorize');
define('ACCESS_TOKEN', constant('URL').'/oauth/accessToken');
define('REQUEST_URI', constant('URL').'/xml');
define('BASE_URL', 'http://'.$_SERVER["SERVER_NAME"].dirname($_SERVER['REQUEST_URI']));
Here is getRequestToken.php
Code: Select all
<?php
header('Content-Type: text/html; charset=utf-8');
require_once 'common.php';
$consumer = new HTTP_OAuth_Consumer(constant('KEY'), constant('SECRET'));
$consumer -> getToken(constant('REQUEST_TOKEN'), constant('BASE_URL').'/getAccessToken.php');
$_SESSION['token'] = $consumer->getToken();
$_SESSION['token_secret'] = $consumer->getTokenSecret();
$url = $consumer->getAuthorizeUrl(constant('AUTHORIZE_TOKEN'));
header('Location:'.$url);
The getAccess.php
Code: Select all
<?php
header('Content-Type: text/html; charset=utf-8');
require_once 'common.php';
$consumer = new HTTP_OAuth_Consumer(constant('KEY'), constant('SECRET'),$_SESSION['token'],$_SESSION['token_secret']);
//I even tried passing the secrete and tokens directly
try {
$consumer->getAccessToken(constant('ACCESS_TOKEN'));
$_SESSION['accessToken'] = $consumer->getToken();
$_SESSION['accessTokenSecret'] = $consumer->getTokenSecret();
header('Location:index.php');
} catch (Exception $e) {
?>
<p>Authorization failed!</p>
<p><a href="index.php">Go back</a></p>
<?php
}
If anyone could tell me what i did wrong would be very helpfull because at this point, the only thing i do with my tellnet is switching on 1 light. I feel like a BigBang theory guy !