-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
43 lines (39 loc) · 1.34 KB
/
index.php
File metadata and controls
43 lines (39 loc) · 1.34 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
41
42
43
<?php
/**
* Created by Mutant Labs
* User: mijahn
* Date: 27/06/13
* Time: 12:03
*/
namespace TwitterRest;
require_once('config.php');
require_once('vendor/autoload.php');
require "TwitterRest/TwitterRestAPI.php";
use TwitterOAuth;
use TwitterRest\TwitterRestAPI;
TwitterRestAPI::create('/')
->addGetRoute('', function(){
$twitterRestApi = new TwitterRestAPI();
$tweets = $twitterRestApi->getCachedUserStatus();
$arrTweets = array();
foreach($tweets as $key => $status) {
$arrTweets[$key] = array(
'created_at' => $status->created_at,
'text' => $status->text
);
}
return $arrTweets;
})
->addGetRoute('authenticate', function(){
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$temporary_credentials = $connection->getRequestToken(OAUTH_CALLBACK);
$redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE);
return array($temporary_credentials,$redirect_url);
})
->addGetRoute('success', function(){
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_GET['oauth_token'],
$_GET['oauth_verifier']);
$token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']);
return array($token_credentials);
})
->run();