-
Notifications
You must be signed in to change notification settings - Fork 2
/
auth.php
26 lines (22 loc) · 984 Bytes
/
auth.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
require_once('config.php');
require('vendor/autoload.php');
use Abraham\TwitterOAuth\TwitterOAuth;
session_start();
if (isset($_POST['image_hash']) && isset($_POST['tweet_text'])){
$_SESSION['image_hash'] = $_POST['image_hash'];
$_SESSION['tweet_text'] = trim($_POST['tweet_text']);
} else if (isset($_GET['image_hash']) && isset($_GET['tweet_text'])){
$_SESSION['image_hash'] = $_GET['image_hash'];
$_SESSION['tweet_text'] = trim(urldecode($_GET['tweet_text']));
} else {
header('Location: ' . HOME);
}
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$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'];
// redirect to auth website
$auth_url = $connection->url('oauth/authorize', array('oauth_token' => $request_token['oauth_token']));
header('Location: ' . $auth_url);
?>