OSDN Git Service

rabr
[embrj/master.git] / lib / twitteroauth.php
1 <?php
2 /*
3  * Abraham Williams (abraham@abrah.am) http://abrah.am
4  *
5  * Basic lib to work with Twitter's OAuth beta. This is untested and should not
6  * be used in production code. Twitter's beta could change at anytime.
7  *
8  * Code based on:
9  * Fire Eagle code - http://github.com/myelin/fireeagle-php-lib
10  * twitterlibphp - http://github.com/jdp/twitterlibphp
11  */
12
13 //require_once('config.php');
14 //require_once('oauth_lib.php');
15
16 /**
17  * Twitter OAuth class
18  */
19 class TwitterOAuth {
20         /* Contains the last HTTP status code returned */
21         public $http_code;
22         /* Contains the last API call */
23         public $last_api_call;
24         /* Set up the API root URL */
25         //public $host = "https://api.twitter.com/1/";
26         public $host = API_URL;
27         /* Set timeout default */
28         public $timeout = 5;
29         /* Set connect timeout */
30         public $connecttimeout = 5;
31         /* Verify SSL Cert */
32         public $ssl_verifypeer = FALSE;
33         /* Respons type */
34         public $type = 'json';
35         /* Decode returne json data */
36         public $decode_json = TRUE;
37         /* Immediately retry the API call if the response was not successful. */
38         //public $retry = TRUE;
39         public $source = 'rabr';
40
41         // user info
42         public $username;
43         public $screen_name;
44         public $user_id;
45
46         /**
47          * Set API URLS
48          */
49         function accessTokenURL()  { return 'https://twitter.com/oauth/access_token'; }
50         function authenticateURL() { return 'https://twitter.com/oauth/authenticate'; }
51         function authorizeURL()    { return 'https://twitter.com/oauth/authorize'; }
52         function requestTokenURL() { return 'https://twitter.com/oauth/request_token'; }
53
54         /**
55          * Debug helpers
56          */
57         function lastStatusCode() { return $this->http_status; }
58         function lastAPICall() { return $this->last_api_call; }
59
60         /**
61          * construct TwitterOAuth object
62          */
63         function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
64                 $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
65                 $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
66                 if (!empty($oauth_token) && !empty($oauth_token_secret)) {
67                         $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
68                         $this->screen_name = $_SESSION['access_token']['screen_name'];
69                         $this->username = $_SESSION['access_token']['screen_name'];
70                         $this->user_id = $_SESSION['access_token']['user_id'];
71                 } else {
72                         $this->token = NULL;
73                 }
74         }
75
76
77         /**
78          * Get a request_token from Twitter
79          *
80          * @returns a key/value array containing oauth_token and oauth_token_secret
81          */
82         function getRequestToken($oauth_callback = NULL) {
83                 $parameters = array();
84                 if (!empty($oauth_callback)) {
85                         $parameters['oauth_callback'] = $oauth_callback;
86                 } 
87                 $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
88                 $token = OAuthUtil::parse_parameters($request);
89                 $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
90                 return $token;
91         }
92
93         /**
94          * Get the authorize URL
95          *
96          * @returns a string
97          */
98         function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) {
99                 if (is_array($token)) {
100                         $token = $token['oauth_token'];
101                 }
102                 if (empty($sign_in_with_twitter)) {
103                         return $this->authorizeURL() . "?oauth_token={$token}";
104                 } else {
105                         return $this->authenticateURL() . "?oauth_token={$token}";
106                 }
107         }
108
109         /**
110          * Exchange the request token and secret for an access token and
111          * secret, to sign API calls.
112          *
113          * @returns array("oauth_token" => the access token,
114          *                "oauth_token_secret" => the access secret)
115          */
116         function getAccessToken($oauth_verifier = FALSE) {
117                 $parameters = array();
118                 if (!empty($oauth_verifier)) {
119                         $parameters['oauth_verifier'] = $oauth_verifier;
120                 }
121                 $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
122                 $token = OAuthUtil::parse_parameters($request);
123                 $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
124                 return $token;
125         }
126
127         /**
128          * GET wrappwer for oAuthRequest.
129          */
130         function get($url, $parameters = array()) {
131                 $response = $this->oAuthRequest($url, 'GET', $parameters);
132                 if($response == false){
133                         return false;
134                 }
135                 if ($this->type == 'json' && $this->decode_json) {
136                         return @json_decode($response);
137                 }elseif($this->type == 'xml' && function_exists('simplexml_load_string')){
138                         return @simplexml_load_string($response);
139                 }
140                 return $response;
141         }
142
143         /**
144          * POST wreapper for oAuthRequest.
145          */
146         function post($url, $parameters = array()) {
147                 $response = $this->oAuthRequest($url, 'POST', $parameters);
148                 if($response === false){
149                         return false;
150                 }
151                 if ($this->type === 'json' && $this->decode_json) {
152                         return json_decode($response);
153                 }elseif($this->type == 'xml' && function_exists('simplexml_load_string')){
154                         return simplexml_load_string($response);
155                 }
156                 return $response;
157         }
158
159         /**
160          * DELTE wrapper for oAuthReqeust.
161          */
162         function delete($url, $parameters = array()) {
163                 $response = $this->oAuthRequest($url, 'DELETE', $parameters);
164                 if($response === false){
165                         return false;
166                 }
167                 if ($this->type === 'json' && $this->decode_json) {
168                         return json_decode($response);
169                 }elseif($this->type == 'xml' && function_exists('simplexml_load_string')){
170                         return simplexml_load_string($response);
171                 }
172                 return $response;
173         }
174
175         /**
176          * Format and sign an OAuth / API request
177          */
178         function oAuthRequest($url, $method, $parameters) {
179                 if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
180                         $url = "{$this->host}{$url}.{$this->type}";
181                 }
182                 $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
183                 $request->sign_request($this->sha1_method, $this->consumer, $this->token);
184                 switch ($method) {
185                 case 'GET':
186                         return $this->http($request->to_url(), 'GET');
187                 default:
188                         return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
189                 }
190         }
191
192         /**
193          * Make an HTTP request
194          *
195          * @return API results
196          */
197         function http($url, $method, $postfields = NULL) {
198                 $ci = curl_init();
199                 /* Curl settings */
200                 curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
201                 curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
202                 curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
203                 curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
204                 curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
205
206                 switch ($method) {
207                 case 'POST':
208                         curl_setopt($ci, CURLOPT_POST, TRUE);
209                         if (!empty($postfields)) {
210                                 curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
211                         }
212                         break;
213                 case 'DELETE':
214                         curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
215                         if (!empty($postfields)) {
216                                 $url = "{$url}?{$postfields}";
217                         }
218                 }
219
220                 curl_setopt($ci, CURLOPT_URL, $url);
221                 $response = curl_exec($ci);
222                 $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
223                 $this->last_api_call = $url;
224                 curl_close ($ci);
225                 return $response;
226         }
227
228         /* ---------- API METHODS ---------- */
229         /*                                   */
230         /* ---------- Block ---------- */
231         function blockingIDs(){
232                 $url = 'blocks/blocking/ids';
233                 return $this->get($url);
234         }
235
236         function blockingList($page){
237                 $url = '/blocks/blocking';
238                 $args = array();
239                 if($page){
240                         $args['page'] = $page;
241                 }
242                 return $this->get($url, $args);
243         }
244
245         function blockUser($id){
246                 $url = $this->host.'/blocks/create';
247                 $url .= "/$id.$this->type";
248                 return $this->post($url);
249         }
250
251         function isBlocked($id){
252                 $url = $this->host.'/blocks/exists';
253                 $url .= "/$id.$this->type";
254                 return $this->get($url);
255         }
256
257         function unblockUser($id){
258                 $url = $this->host.'/blocks/destroy';
259                 $url .= "/$id.$this->type";
260                 return $this->delete($url);
261         }
262
263         /* ---------- Messages ---------- */
264         function deleteDirectMessage($id){
265                 $url = $this->host.'/direct_messages/destroy';
266                 $url .= "/$id.$this->type";
267                 return $this->delete($url);
268         }
269
270         function directMessages($page = false, $since_id = false, $count = null){
271                 $url = '/direct_messages';
272                 $args = array();
273                 if( $since_id )
274                         $args['since_id'] = $since_id;
275                 if( $page )
276                         $args['page'] = $page;
277                 return $this->get($url, $args);
278         }
279
280         function sendDirectMessage($user, $text){
281                 $url = '/direct_messages/new';
282                 $args = array();
283                 $args['user'] = $user;
284                 if($text)
285                         $args['text'] = $text;
286                 return $this->post($url, $args);
287         }
288
289         function sentDirectMessage($page = false, $since = false, $since_id = false){
290                 $url = '/direct_messages/sent';
291                 $args = array();
292                 if($since)
293                         $args['since'] = $since;
294                 if($since_id)
295                         $args['since_id'] = $since_id;
296                 if($page)
297                         $args['page'] = $page;
298                 return $this->get($url, $args);
299         }
300
301         /* ---------- List ---------- */
302         function addListMember($listid, $memberid){
303                 $url = "/1/$this->username/$listid/members";
304                 $args = array();
305                 if($memberid){
306                         $args['id'] = $memberid;
307                 }
308                 return $this->post($url, $args);
309         }
310
311         function beAddedLists($username = '', $cursor = false){
312                 $url = $this->host."/$username/lists/memberships.$this->type";
313                 $args = array();
314                 if($cursor){
315                         $args['cursor'] = $cursor;
316                 }
317                 return $this->get($url, $args);
318         }
319
320         function createList($name, $description, $isPortect){
321                 $url = "/$this->username/lists";
322                 $args = array();
323                 if($name){
324                         $args['name'] = $name;
325                 }
326                 if($description){
327                         $args['description'] = $description;
328                 }
329                 if($isProtect){
330                         $args['mode'] = 'private';
331                 }
332                 return $this->post($url, $args);
333         }
334
335         function createdLists($username = '', $cursor = false){
336                 $url = $this->host."/$username/lists.$this->type";
337                 $args = array();
338                 if($cursor){
339                         $args['cursor'] = $cursor;
340                 }
341                 return $this->get($url, $args);
342         }
343
344         function deleteList($id){
345                 $arr = explode('/', $id);
346                 $url = "/$arr[0]/lists/$arr[1]";
347                 return $this->delete($url);
348         }
349
350         function deleteListMember($id, $memberid){
351                 $arr = explode("/", $id);
352                 $url = "/1/".$arr[0]."/".$arr[1]."/members";
353                 $args = array();
354                 if($memberid){
355                         $args['id'] = $memberid;
356                 }
357                 return $this->delete($url, $args);
358         }
359
360         function editList($prename, $name, $description, $isProtect){
361                 $url = "$this->username/lists/$prename";
362                 $args = array();
363                 if($name){
364                         $args['name'] = $name;
365                 }
366                 if($description){
367                         $args['description'] = $description;
368                 }
369                 if($isProtect){
370                         $args['mode'] = "private";
371                 }
372                 return $this->post($url, $args);
373         }
374
375         function followedLists($username = '', $cursor = false){
376                 $url = $this->host."/$username/lists/subscriptions.$this->type";
377                 $args = array();
378                 if($cursor){
379                         $args['cursor'] = $cursor;
380                 }
381                 return $this->get($url, $args);
382         }
383
384         function followList($id){
385                 $arr = explode("/", $id);
386                 $url = $this->host."/1/$arr[0]/$arr[1]/subscribers/$this->type";
387                 return $this->post($url, $args);
388         }
389
390         function isFollowedList($id){
391                 $arr = explode('/', $id);
392                 $url = $this->host."/$arr[0]/$arr[1]/subscribers/$this->username.$this->type";
393                 return $this->get($url);
394         }
395
396         function listFollowers($id, $cursor = false){
397                 $arr = explode('/', $id);
398                 $url = $this->host."/1/$arr[0]/$arr[1]/subscribers.$this->type";
399                 $args = array();
400                 if($cursor){
401                         $args['cursor'] = $cursor;
402                 }
403                 return $this->get($url, $args);
404         }
405
406         function listInfo($id){
407                 $arr = explode('/', $id);
408                 $url = $this->host."/$arr[0]/lists/$arr[1].$this->type";
409                 return $this->get($url);
410         }
411
412         function listMembers($id, $cursor = false){
413                 $arr = explode("/", $id);
414                 $url = $this->host."/1/$arr[0]/$arr[1]/members.$this->type";
415                 $args = array();
416                 if($cursor){
417                         $args['cursor'] = $cursor;
418                 }
419                 return $this->get($url, $args);
420
421         }
422
423         function listStatus($id, $page = false, $since_id = false){
424                 $arr = explode('/', $id);
425                 $url = $this->host."/$arr[0]/lists/$arr[1]/statuses.$this->type";
426                 $args = array();
427                 if($page){
428                         $args['page'] = $page;
429                 }
430                 if($since_id){
431                         $args['since_id'] = $since_id;
432                 }
433                 return $this->get($url, $args);
434         }
435
436         function unfollowList($id){
437                 $arr = explode("/", $id);
438                 $url = $this->host."/1/$arr[0]/$arr[1]/subscribers.$this->type";
439                 return $this->delete($url);
440         }
441
442         /* ---------- Friendship ---------- */
443         function destroyUser($id){
444                 $url = $this->host.'/friendships/destroy';
445                 $url .= "/$id.$this->type";
446                 return $this->delete($url);
447         }
448
449         function followers($id = false, $page = false, $count = 30){
450                 $url = $this->host.'/statuses/followers';
451                 $url .= $id ? "/$id.$this->type" : ".$this->type";
452                 if( $id )
453                         $args['id'] = $id;
454                 if( $count )
455                         $args['count'] = (int) $count;
456                 $args['cursor'] = $page ? $page : -1;
457                 return $this->get($url, $args);
458         }
459
460         function followUser($id, $notifications = false){
461                 $url = $this->host.'/friendships/create';
462                 $url .= "/$id.$this->type";
463                 $args = array();
464                 if($notifications)
465                         $args['follow'] = true;
466                 return $this->post($url, $args);
467         }
468
469         function friends($id = false, $page = false, $count = 30){
470                 $url = $this->host.'/statuses/friends';
471                 $url .= $id ? "/$id.$this->type" : ".$this->type";
472                 $args = array();
473                 if( $id )
474                         $args['id'] = $id;
475                 if( $count )
476                         $args['count'] = (int) $count;
477                 $args['cursor'] = $page ? $page : -1;
478                 return $this->get($url, $args);
479         }
480
481         function isFriend($user_a, $user_b){
482                 $url = '/friendships/exists';
483                 $args = array();
484                 $args['user_a'] = $user_a;
485                 $args['user_b'] = $user_b;
486                 return $this->get($url, $args);
487         }
488
489         function relationship($target, $source = false){
490                 $url = API_TWITTER.'/1/friendships/show.'.$this->type;
491                 $args = array();
492                 $args['target_screen_name'] = $target;
493                 if($source){
494                         $args['source_screen_name'] = $source;
495                 }
496                 return $this->get($url, $args);
497         }
498
499         function showUser($id = false, $email = false, $user_id = false, $screen_name = false){
500                 $url = '/users/show';
501                 $args = array();
502                 if($id)
503                         $args['id'] = $id;
504                 elseif($screen_name)
505                         $args['id'] = $screen_name;
506                 else
507                         $args['id'] = $this->user_id;
508
509                 return $this->get($url, $args);
510         }
511
512         /* ---------- Ratelimit ---------- */
513         function ratelimit(){
514                 $url = '/account/rate_limit_status';
515                 return $this->get($url);
516         }
517
518         function ratelimit_status(){
519                 return $this->ratelimit();
520         }
521
522         /* ---------- Retweet ---------- */
523         function getRetweeters($id, $count = false){
524                 $url = $this->host."/1/statuses/retweets/$id.$this->type";
525                 if($count != false){
526                         $url .= "?count=$count";
527                 }
528                 return $this->get($url);
529         }
530
531         function retweet($id){
532                 $url = "http://api.twitter.com/1/statuses/retweet/$id.$this->type";
533                 return $this->post($url);
534         }
535
536         function retweets($id, $count = 20){
537                 if($count > 100){
538                         $count = 100;
539                 }
540                 $url = "http://api.twitter.com/1/statuses/retweets/id.$this->type?count=$count";
541                 return $this->get($url);
542         }
543
544         // Returns the 20 most recent retweets posted by the authenticating user.
545         function retweeted_by_me($page = false, $count = 20, $since_id = false, $max_id = false){
546                 $url = "http://api.twitter.com/1/statuses/retweeted_by_me.$this->type";
547                 $args = array();
548                 if($since_id){
549                         $args['since_id'] = $since_id;
550                 }
551                 if($max_id){
552                         $args['max_id'] = $max_id;
553                 }
554                 if($count){
555                         $args['count'] = $count;
556                 }
557                 if($page){
558                         $args['page'] = $page;
559                 }
560                 return $this->get($url, $args);
561         }
562
563         // Returns the 20 most recent retweets posted by the authenticating user's friends.
564         function retweeted_to_me($page = false, $count = false, $since_id = false, $max_id = false){
565                 $url = "http://api.twitter.com/1/statuses/retweeted_to_me.$this->type";
566                 $args = array();
567                 if($since_id){
568                         $args['since_id'] = $since_id;
569                 }
570                 if($max_id){
571                         $args['max_id'] = $max_id;
572                 }
573                 if($count){
574                         $args['count'] = $count;
575                 }
576                 if($page){
577                         $args['page'] = $page;
578                 }
579                 return $this->get($url, $args);
580         }
581
582         function retweets_of_me($page = false, $count = false, $since_id = false, $max_id = false){
583                 $url = "http://api.twitter.com/1/statuses/retweets_of_me.$this->type";
584                 $args = array();
585                 if($since_id){
586                         $args['since_id'] = $since_id;
587                 }
588                 if($max_id){
589                         $args['max_id'] = $max_id;
590                 }
591                 if($count){
592                         $args['count'] = $count;
593                 }
594                 if($page){
595                         $args['page'] = $page;
596                 }
597                 return $this->get($url, $args);
598         }
599
600         /* ---------- Search ---------- */
601         function search($q = false, $page = false, $rpp = false){
602                 $url = '/search';
603                 if(!$q)
604                         return false;
605                 $args = array();
606                 if($page){
607                         $args['page'] = $page;
608                 }
609                 if($rpp){
610                         $args['rpp'] = $rpp;
611                 }
612                 $args['q'] = $q;
613                 return $this->get($url, $args);
614         }
615
616         /* ---------- Spam ---------- */
617         function reportSpam($screen_name){
618                 $url = API_TWITTER."/1/report_spam.$this->type";
619                 $args = array();
620                 $args['screen_name'] = $screen_name;
621                 return $this->post($url, $args);
622         }
623
624         /* ---------- Timeline ---------- */
625         function deleteStatus($id){
626                 $url = $this->host.'/statuses/destroy';
627                 $url .= "/$id.$this->type";
628                 return $this->delete($url);
629         }
630
631         function friendsTimeline($page = false, $since_id = false, $count = false){
632                 $url = '/statuses/friends_timeline';
633                 $args = array();
634                 if($page)
635                         $args['page'] = $page;
636                 if($since_id)
637                         $args['since_id'] = $since_id;
638                 if($count)
639                         $args['count'] = $count;
640                 return $this->get($url, $args);
641         }
642
643         function getFavorites($page = false){
644                 $url = '/favorites';
645                 $args = array();
646                 if($page)
647                         $args['page'] = $page;
648                 return $this->get($url, $args);
649         }
650
651         function makeFavorite($id){
652                 $url = $this->host.'/favorites/create/';
653                 $url .= "$id.$this->type";
654                 return $this->post($url);
655         }
656
657         function publicTimeline($sinceid = false){
658                 $url = '/statuses/public_timeline';
659                 $args = array();
660                 if($sinceid){
661                         $args['since_id'] = $sinceid;
662                 }
663                 return $this->get($url, $args);
664         }
665
666         function removeFavorite($id){
667                 $url = $this->host.'/favorites/destroy/';
668                 $url .= "$id.$this->type";
669                 return $this->post($url);
670         }
671
672         function replies($page = false, $since_id = false){
673                 $url = '/statuses/mentions';
674                 $args = array();
675                 if($page)
676                         $args['page'] = (int) $page;
677                 if($since_id)
678                         $args['since_id'] = $since_id;
679                 return $this->get($url, $args);
680         }
681
682         function showStatus($id){
683                 $url = $this->host.'/statuses/show';
684                 $url .= "/$id.$this->type";
685                 return $this->get($url);
686         }
687
688         function update($status, $replying_to = false){
689                 try{
690                         $url = '/statuses/update';
691                         $args = array();
692                         $args['status'] = $status;
693                         if($replying_to)
694                                 $args['in_reply_to_status_id'] = $replying_to;
695                         return $this->post($url, $args);
696                 }catch(Exception $ex){
697                         echo $ex->getLine." : ".$ex->getMessage();
698                 }
699         }
700
701         function userTimeline($page = false, $id = false, $count = false, $since_id = false){
702                 $url = '/statuses/user_timeline';
703                 $args = array();
704                 if($page)
705                         $args['page'] = $page;
706                 if($id)
707                         $args['id'] = $id;
708                 if($count)
709                         $args['count'] = $count;
710                 if($since_id)
711                         $args['since_id'] = $since_id;
712                 $response = $this->get($url, $args);
713                 if($response->error === 'Not authorized'){
714                         return 'protected';
715                 }
716                 return $response;
717         }
718
719         function trends(){
720                 $url = "http://search.twitter.com/trends.$this->type";
721                 return $this->get($url);
722         }
723
724         /* ---------- Misc. ---------- */
725         function twitterAvailable(){
726                 $url = "/help/test";
727                 if($this->get($url) == 'ok'){
728                         return true;
729                 }
730                 return false;
731         }
732
733         function updateProfile($fields = array()){
734                 $url = '/account/update_profile';
735                 $args = array();
736                 foreach( $fields as $pk => $pv ){
737                         switch( $pk ){
738                         case 'name' :
739                                 $args[$pk] = (string) substr( $pv, 0, 20 );
740                                 break;
741                         case 'email' :
742                                 if( preg_match( '/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $pv ) )
743                                         $args[$pk] = (string) $pv;
744                                 break;
745                         case 'url' :
746                                 $args[$pk] = (string) substr( $pv, 0, 100 );
747                                 break;
748                         case 'location' :
749                                 $args[$pk] = (string) substr( $pv, 0, 30 );
750                                 break;
751                         case 'description' :
752                                 $args[$pk] = (string) substr( $pv, 0, 160 );
753                                 break;
754                         default :
755                                 break;
756                         }
757                 }
758                 return $this->post($url, $args);
759         }
760
761         function veverify(){
762                 $url = $this->host.'/account/verify_credentials.'.$this->type;
763                 return $this->get($url);
764         }
765
766         /* ---------- image upload ---------- */
767         function imglyUpload($image){
768                 $imgly = new image_uploader();
769                 return is_null($imgly->imgly($image));
770         }
771
772         /* ---------- twitese method ---------- */
773         function rank($page = false, $count = false){
774                 $url = TWITESE_API_URL."/rank.$this->type";
775                 $args = array();
776                 if($page){
777                         $args['page'] = $page;
778                 }
779                 if($count){
780                         $args['count'] = $count;
781                 }
782                 return $this->get($url, $args);
783         }
784
785         function browse($page = false, $count = false){
786                 $url = TWITESE_API_URL."/browse.$this->type";
787                 $args = array();
788                 if($page){
789                         $args['page'] = $page;
790                 }
791                 if($count){
792                         $args['count'] = $count;
793                 }
794                 return $this->get($url, $args);
795         }
796 }
797