forked from igitur/snapbird
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.php
executable file
·42 lines (33 loc) · 1.3 KB
/
proxy.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
include('auth/secret.php');
include('auth/php/EpiCurl.php');
include('auth/php/EpiOAuth.php');
include('auth/php/EpiTwitter.php');
$twitterObj = new EpiTwitter(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
$twitterInfo = null;
$timeline = null;
$callback = $_GET['callback'];
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$type = isset($_GET['type']) ? $_GET['type'] : 'statusesFriends_timeline';
$data = '[]';
if ($_COOKIE['token'] && file_exists('auth/oauth/' . $_COOKIE['token'])) {
$username = file_get_contents('auth/oauth/' . $_COOKIE['token']);
$userToken = $_COOKIE['token'];
$userSecret = file_get_contents('auth/oauth/' . $username . '-sec');
$twitterObj->setToken($userToken, $userSecret);
$twitterInfo = $twitterObj->get_accountVerify_credentials();
// why I have to probe twitterInfo I'll never know
if ($twitterInfo->screen_name) {}
$method = "get_" . $type;
$timeline = $twitterObj->$method(array('count' => 200, 'page' => $page));
$data = json_encode($timeline->response);
// if twitter is over capcity, try to avoid it borking
if (stripos($data, 'Over capacity') !== false) {
$data = '{ "error": "Over capacity", results: [] }';
} else {
error_log($data);
$data = '{ "error": "data returned empty", results: [] }';
}
}
echo $callback . '(' . $data . ')';
?>