forked from xmakina/TweetToList
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetUpTwitterObject.php
More file actions
40 lines (30 loc) · 1.09 KB
/
Copy pathSetUpTwitterObject.php
File metadata and controls
40 lines (30 loc) · 1.09 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once("db.class.php");
function Authenticate() {
if (isset($_GET["listid"]) && isset($_GET["message"])) {
$listid = $_GET["listid"];
$message = urlencode($_GET["message"]);
// ListId and Message were set, remember them
setcookie("listid", $listid);
setcookie("message", $message);
}
$twitterObject = new EpiTwitter(CONSUMER_KEY, CONSUMER_SECRET);
header("Location: " . $twitterObject->getAuthenticateUrl());
die();
}
function SetUpTwitterObject() {
if (!isset($_COOKIE["twitterid"]) || !isset($_COOKIE["oauth_token"]) || !isset($_COOKIE["oauth_token_secret"])) {
// Cookies not set, authenticate
$twitterObject = new EpiTwitter(CONSUMER_KEY, CONSUMER_SECRET);
Authenticate();
}
$twitterObject = new EpiTwitter(CONSUMER_KEY, CONSUMER_SECRET,
$_COOKIE["oauth_token"], $_COOKIE["oauth_token_secret"]);
try {
$twitterInfo = $twitterObject->get("/account/verify_credentials.json");
} catch (Exception $e) {
Authenticate();
}
return $twitterObject;
}
?>