<?php
session_start();

require('../include/twitteroauth/autoload.php');
use Abraham\TwitterOAuth\TwitterOAuth;

include("../twitter.secret");

define('CONSUMER_KEY', $consumer_key);
define('CONSUMER_SECRET', $consumer_secret);
define('OAUTH_CALLBACK', "https://ask.fai.su/from_twitter.php");

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$connection->setTimeouts(10, 15);

$request_token = $connection->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK));

$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];

$url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
header("Location: $url");

?>
