31 lines
1.2 KiB
PHP
Executable File
31 lines
1.2 KiB
PHP
Executable File
<?php
|
|
session_start();
|
|
ini_set('display_errors', 1);
|
|
require 'autoload.php';
|
|
use Abraham\TwitterOAuth\TwitterOAuth;
|
|
require_once('config.php');
|
|
|
|
/* Prepara la conexión */
|
|
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
|
|
|
|
/* Solicita a twitter las credenciales temporales */
|
|
//$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
|
|
$request_token = $connection->oauth('oauth/request_token');
|
|
|
|
/* Guarda la credenciales temporales en sesión. */
|
|
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
|
|
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
|
|
//switch ($connection->http_code) {
|
|
// case 200:
|
|
/* Construye la url de autorización y envía al usuario a Twitter. */
|
|
$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
|
|
//$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
|
|
//$url = $connection->getAuthorizeURL($token);
|
|
// print $url;
|
|
header('Location: ' . $url);
|
|
//break;
|
|
// default:
|
|
/* Indica que se ha producido un error. */
|
|
// echo 'Error de conexión a Twitter.';
|
|
// echo "\nHTTP CODE: " . $connection->http_code;
|
|
//}
|