git-svn-id: https://192.168.0.254/svn/Proyectos.Uecko_Web/trunk@2 8c1a5cbb-1905-e346-a7f4-bd4d5d3abd07
29 lines
954 B
PHP
29 lines
954 B
PHP
<?php
|
|
|
|
/* Start session and load library. */
|
|
session_start();
|
|
require_once('twitteroauth/twitteroauth.php');
|
|
require_once('config.php');
|
|
|
|
/* Build TwitterOAuth object with client credentials. */
|
|
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
|
|
|
|
/* Get temporary credentials. */
|
|
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
|
|
|
|
/* Save temporary credentials to session. */
|
|
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
|
|
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
|
|
|
|
/* If last connection failed don't display authorization link. */
|
|
switch ($connection->http_code) {
|
|
case 200:
|
|
/* Build authorize URL and redirect user to Twitter. */
|
|
$url = $connection->getAuthorizeURL($token);
|
|
header('Location: ' . $url);
|
|
break;
|
|
default:
|
|
/* Show notification if something went wrong. */
|
|
echo 'Could not connect to Twitter. Refresh the page or try again later.';
|
|
}
|