forked from antpaw/kohana_twitteroauth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage-example.php
61 lines (50 loc) · 1.79 KB
/
usage-example.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Mytwitterapi extends Controller_Twitter {
/*
public function before()
{
parent::before();
$this->request->headers = array('Content-type' => 'application/json');
}
*/
public function action_home_timeline($page = 0)
{
$twitter = $this->check_for_login();
$twitter->decode_json = FALSE;
$json = json_decode($twitter->get('statuses/home_timeline', array('count' => '10', 'page' => $page)), TRUE);
$better_json = array();
$json_count = count($json);
for($i = 0; $i < $json_count; $i++)
{
$c = $json[$i];
$better_json['results'][] = array(
'id' => $c['id'],
'from_user_id' => $c['user']['id'],
'from_user' => $c['user']['screen_name'],
'profile_image_url' => $c['user']['profile_image_url'],
'created_at' => $c['created_at'],
'to_user_id' => $c['in_reply_to_user_id'],
'text' => $c['text'],
'geo' => $c['geo'],
'source' => $c['source'],
);
}
echo json_encode($better_json);
}
public function action_user_timeline($page = 0)
{
$twitter = $this->check_for_login();
print Kohana::debug($twitter->get('statuses/user_timeline', array('count' => '10', 'page' => $page)));
}
public function action_search($page = 1)
{
$twitter = $this->check_for_login();
$q = Security::xss_clean(Arr::get($_GET, 'q', 'kittens'));
print Kohana::debug($twitter->get('search', array('q' => $q, 'rpp' => '10', 'page' => $page)));
}
// get('account/verify_credentials');
// get('users/show', array('screen_name' => 'obama'));
// post('statuses/update', array('status' => 'I like #Kohana, #TwitterOAuth PHP lib and #turtles'));
// post('statuses/destroy', array('id' => 5437877770));
// post('friendships/create', array('screen_name' => 'obama'));
}