2 require_once("bbcode.php");
3 require_once("datetime.php");
4 require_once("conversation.php");
5 require_once("oauth.php");
6 require_once("html2plain.php");
15 function api_date($str){
16 //Wed May 23 06:01:13 +0000 2007
17 return datetime_convert('UTC', 'UTC', $str, "D M d H:i:s +0000 Y" );
21 function api_register_func($path, $func, $auth=false){
23 $API[$path] = array('func'=>$func,
31 function api_login(&$a){
34 $oauth = new FKOAuth1();
35 list($consumer,$token) = $oauth->verify_request(OAuthRequest::from_request());
36 if (!is_null($token)){
37 $oauth->loginUser($token->uid);
38 call_hooks('logged_in', $a->user);
41 echo __file__.__line__.__function__."<pre>"; var_dump($consumer, $token); die();
43 logger(__file__.__line__.__function__."\n".$e);
44 //die(__file__.__line__.__function__."<pre>".$e); die();
49 // workaround for HTTP-auth in CGI mode
50 if(x($_SERVER,'REDIRECT_REMOTE_USER')) {
51 $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"],6)) ;
52 if(strlen($userpass)) {
53 list($name, $password) = explode(':', $userpass);
54 $_SERVER['PHP_AUTH_USER'] = $name;
55 $_SERVER['PHP_AUTH_PW'] = $password;
59 if (!isset($_SERVER['PHP_AUTH_USER'])) {
60 logger('API_login: ' . print_r($_SERVER,true), LOGGER_DEBUG);
61 header('WWW-Authenticate: Basic realm="Friendica"');
62 header('HTTP/1.0 401 Unauthorized');
63 die('This api requires login');
66 $user = $_SERVER['PHP_AUTH_USER'];
67 $encrypted = hash('whirlpool',trim($_SERVER['PHP_AUTH_PW']));
71 * next code from mod/auth.php. needs better solution
74 // process normal login request
76 $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
77 AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
85 logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
86 header('WWW-Authenticate: Basic realm="Friendica"');
87 header('HTTP/1.0 401 Unauthorized');
88 die('This api requires login');
91 require_once('include/security.php');
92 authenticate_success($record);
94 call_hooks('logged_in', $a->user);
98 /**************************
99 * MAIN API ENTRY POINT *
100 **************************/
101 function api_call(&$a){
102 GLOBAL $API, $called_api;
107 foreach ($API as $p=>$info){
108 if (strpos($a->query_string, $p)===0){
109 $called_api= explode("/",$p);
110 //unset($_SERVER['PHP_AUTH_USER']);
111 if ($info['auth']===true && local_user()===false) {
115 load_contact_links(local_user());
117 logger('API call for ' . $a->user['username'] . ': ' . $a->query_string);
118 logger('API parameters: ' . print_r($_REQUEST,true));
120 if (strpos($a->query_string, ".xml")>0) $type="xml";
121 if (strpos($a->query_string, ".json")>0) $type="json";
122 if (strpos($a->query_string, ".rss")>0) $type="rss";
123 if (strpos($a->query_string, ".atom")>0) $type="atom";
124 if (strpos($a->query_string, ".as")>0) $type="as";
126 $r = call_user_func($info['func'], $a, $type);
127 if ($r===false) return;
131 $r = mb_convert_encoding($r, "UTF-8",mb_detect_encoding($r));
132 header ("Content-Type: text/xml");
133 return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
136 //header ("Content-Type: application/json");
138 return json_encode($rr);
141 header ("Content-Type: application/rss+xml");
142 return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
145 header ("Content-Type: application/atom+xml");
146 return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
149 //header ("Content-Type: application/json");
151 // return json_encode($rr);
152 return json_encode($r);
156 //echo "<pre>"; var_dump($r); die();
159 logger('API call not implemented: '.$a->query_string." - ".print_r($_REQUEST,true));
160 $r = '<status><error>not implemented</error></status>';
163 header ("Content-Type: text/xml");
164 return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
167 header ("Content-Type: application/json");
168 return json_encode(array('error' => 'not implemented'));
171 header ("Content-Type: application/rss+xml");
172 return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
175 header ("Content-Type: application/atom+xml");
176 return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
184 function api_rss_extra(&$a, $arr, $user_info){
185 if (is_null($user_info)) $user_info = api_get_user($a);
186 $arr['$user'] = $user_info;
187 $arr['$rss'] = array(
188 'alternate' => $user_info['url'],
189 'self' => $a->get_baseurl(). "/". $a->query_string,
190 'base' => $a->get_baseurl(),
191 'updated' => api_date(null),
192 'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
193 'language' => $user_info['language'],
194 'logo' => $a->get_baseurl()."/images/friendica-32.png",
201 * Returns user info array.
203 function api_get_user(&$a, $contact_id = Null){
209 if(!is_null($contact_id)){
211 $extra_query = "AND `contact`.`id` = %d ";
214 if(is_null($user) && x($_GET, 'user_id')) {
215 $user = intval($_GET['user_id']);
216 $extra_query = "AND `contact`.`id` = %d ";
218 if(is_null($user) && x($_GET, 'screen_name')) {
219 $user = dbesc($_GET['screen_name']);
220 $extra_query = "AND `contact`.`nick` = '%s' ";
221 if (local_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(local_user());
225 if (is_null($user) && $a->argc > (count($called_api)-1)){
226 $argid = count($called_api);
227 list($user, $null) = explode(".",$a->argv[$argid]);
228 if(is_numeric($user)){
229 $user = intval($user);
230 $extra_query = "AND `contact`.`id` = %d ";
232 $user = dbesc($user);
233 $extra_query = "AND `contact`.`nick` = '%s' ";
234 if (local_user()!==false) $extra_query .= "AND `contact`.`uid`=".intval(local_user());
239 if (local_user()===false) {
240 api_login($a); return False;
242 $user = $_SESSION['uid'];
243 $extra_query = "AND `contact`.`uid` = %d AND `contact`.`self` = 1 ";
248 logger('api_user: ' . $extra_query . ' ' , $user);
250 $uinfo = q("SELECT *, `contact`.`id` as `cid` FROM `contact`
255 if (count($uinfo)==0) {
259 if($uinfo[0]['self']) {
260 $usr = q("select * from user where uid = %d limit 1",
263 $profile = q("select * from profile where uid = %d and `is-default` = 1 limit 1",
267 // count public wall messages
268 $r = q("SELECT COUNT(`id`) as `count` FROM `item`
271 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
272 intval($uinfo[0]['uid'])
274 $countitms = $r[0]['count'];
277 $r = q("SELECT COUNT(`id`) as `count` FROM `item`
278 WHERE `contact-id` = %d
279 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
280 intval($uinfo[0]['id'])
282 $countitms = $r[0]['count'];
286 $r = q("SELECT COUNT(`id`) as `count` FROM `contact`
287 WHERE `uid` = %d AND `rel` IN ( %d, %d )
288 AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0",
289 intval($uinfo[0]['uid']),
290 intval(CONTACT_IS_SHARING),
291 intval(CONTACT_IS_FRIEND)
293 $countfriends = $r[0]['count'];
295 $r = q("SELECT COUNT(`id`) as `count` FROM `contact`
296 WHERE `uid` = %d AND `rel` IN ( %d, %d )
297 AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0",
298 intval($uinfo[0]['uid']),
299 intval(CONTACT_IS_FOLLOWER),
300 intval(CONTACT_IS_FRIEND)
302 $countfollowers = $r[0]['count'];
304 $r = q("SELECT count(`id`) as `count` FROM item where starred = 1 and uid = %d and deleted = 0",
305 intval($uinfo[0]['uid'])
307 $starred = $r[0]['count'];
310 if(! $uinfo[0]['self']) {
317 'id' => intval($uinfo[0]['cid']),
318 'self' => intval($uinfo[0]['self']),
319 'uid' => intval($uinfo[0]['uid']),
320 'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
321 'screen_name' => (($uinfo[0]['nick']) ? $uinfo[0]['nick'] : $uinfo[0]['name']),
322 'location' => ($usr) ? $usr[0]['default-location'] : '',
323 'profile_image_url' => $uinfo[0]['micro'],
324 'url' => $uinfo[0]['url'],
325 'contact_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'],
326 'protected' => false,
327 'friends_count' => intval($countfriends),
328 'created_at' => api_date($uinfo[0]['name-date']),
329 'utc_offset' => "+00:00",
330 'time_zone' => 'UTC', //$uinfo[0]['timezone'],
331 'geo_enabled' => false,
332 'statuses_count' => intval($countitms), #XXX: fix me
333 'lang' => 'en', #XXX: fix me
334 'description' => (($profile) ? $profile[0]['pdesc'] : ''),
335 'followers_count' => intval($countfollowers),
336 'favourites_count' => intval($starred),
337 'contributors_enabled' => false,
338 'follow_request_sent' => true,
339 'profile_background_color' => 'cfe8f6',
340 'profile_text_color' => '000000',
341 'profile_link_color' => 'FF8500',
342 'profile_sidebar_fill_color' =>'AD0066',
343 'profile_sidebar_border_color' => 'AD0066',
344 'profile_background_image_url' => '',
345 'profile_background_tile' => false,
346 'profile_use_background_image' => false,
347 'notifications' => false,
348 'following' => '', #XXX: fix me
349 'verified' => true, #XXX: fix me
357 function api_item_get_user(&$a, $item) {
360 // The author is our direct contact, in a conversation with us.
361 if(link_compare($item['url'],$item['author-link'])) {
362 return api_get_user($a,$item['cid']);
365 // The author may be a contact of ours, but is replying to somebody else.
366 // Figure out if we know him/her.
367 $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
368 if(($normalised != 'mailbox') && (x($a->contacts[$normalised])))
369 return api_get_user($a,$a->contacts[$normalised]['id']);
371 // We don't know this person directly.
373 list($nick, $name) = array_map("trim",explode("(",$item['author-name']));
374 $name=str_replace(")","",$name);
382 // Generating a random ID
383 if (!array_key_exists($nick, $usercache))
384 $usercache[$nick] = mt_rand(2000000, 2100000);
387 'id' => $usercache[$nick],
389 'screen_name' => $nick,
390 'location' => '', //$uinfo[0]['default-location'],
392 'profile_image_url' => $item['author-avatar'],
393 'url' => $item['author-link'],
394 'protected' => false, #
395 'followers_count' => 0,
396 'friends_count' => 0,
398 'favourites_count' => 0,
399 'utc_offset' => 0, #XXX: fix me
400 'time_zone' => '', //$uinfo[0]['timezone'],
401 'statuses_count' => 0,
403 'statusnet_blocking' => false,
404 'notifications' => false,
407 'geo_enabled' => false,
408 'lang' => 'en', #XXX: fix me
409 'contributors_enabled' => false,
410 'follow_request_sent' => false,
411 'profile_background_color' => 'cfe8f6',
412 'profile_text_color' => '000000',
413 'profile_link_color' => 'FF8500',
414 'profile_sidebar_fill_color' =>'AD0066',
415 'profile_sidebar_border_color' => 'AD0066',
416 'profile_background_image_url' => '',
417 'profile_background_tile' => false,
418 'profile_use_background_image' => false,
419 'verified' => true, #XXX: fix me
420 'followers' => '', #XXX: fix me
429 * load api $templatename for $type and replace $data array
431 function api_apply_template($templatename, $type, $data){
439 $data = array_xmlify($data);
440 $tpl = get_markup_template("api_".$templatename."_".$type.".tpl");
441 $ret = replace_macros($tpl, $data);
455 * Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful;
456 * returns a 401 status code and an error message if not.
457 * http://developer.twitter.com/doc/get/account/verify_credentials
459 function api_account_verify_credentials(&$a, $type){
460 if (local_user()===false) return false;
461 $user_info = api_get_user($a);
463 return api_apply_template("user", $type, array('$user' => $user_info));
466 api_register_func('api/account/verify_credentials','api_account_verify_credentials', true);
470 * get data from $_POST or $_GET
472 function requestdata($k){
473 if (isset($_POST[$k])){
476 if (isset($_GET[$k])){
482 /*Waitman Gobble Mod*/
483 function api_statuses_mediap(&$a, $type) {
484 if (local_user()===false) {
485 logger('api_statuses_update: no user');
488 $user_info = api_get_user($a);
490 $_REQUEST['type'] = 'wall';
491 $_REQUEST['profile_uid'] = local_user();
492 $_REQUEST['api_source'] = true;
493 $txt = urldecode(requestdata('status'));
495 require_once('library/HTMLPurifier.auto.php');
496 require_once('include/html2bbcode.php');
498 if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
499 $txt = html2bb_video($txt);
500 $config = HTMLPurifier_Config::createDefault();
501 $config->set('Cache.DefinitionImpl', null);
502 $purifier = new HTMLPurifier($config);
503 $txt = $purifier->purify($txt);
505 $txt = html2bbcode($txt);
507 $a->argv[1]=$user_info['screen_name']; //should be set to username?
509 $_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
510 require_once('mod/wall_upload.php');
511 $bebop = wall_upload_post($a);
513 //now that we have the img url in bbcode we can add it to the status and insert the wall item.
514 $_REQUEST['body']=$txt."\n\n".$bebop;
515 require_once('mod/item.php');
518 // this should output the last post (the one we just posted).
519 return api_status_show($a,$type);
521 api_register_func('api/statuses/mediap','api_statuses_mediap', true);
522 /*Waitman Gobble Mod*/
525 function api_statuses_update(&$a, $type) {
526 if (local_user()===false) {
527 logger('api_statuses_update: no user');
530 $user_info = api_get_user($a);
532 // convert $_POST array items to the form we use for web posts.
534 // logger('api_post: ' . print_r($_POST,true));
536 if(requestdata('htmlstatus')) {
537 require_once('library/HTMLPurifier.auto.php');
538 require_once('include/html2bbcode.php');
540 $txt = requestdata('htmlstatus');
541 if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
543 $txt = html2bb_video($txt);
545 $config = HTMLPurifier_Config::createDefault();
546 $config->set('Cache.DefinitionImpl', null);
549 $purifier = new HTMLPurifier($config);
550 $txt = $purifier->purify($txt);
552 $_REQUEST['body'] = html2bbcode($txt);
557 $_REQUEST['body'] = urldecode(requestdata('status'));
559 $parent = requestdata('in_reply_to_status_id');
560 if(ctype_digit($parent))
561 $_REQUEST['parent'] = $parent;
563 $_REQUEST['parent_uri'] = $parent;
565 if(requestdata('lat') && requestdata('long'))
566 $_REQUEST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
567 $_REQUEST['profile_uid'] = local_user();
568 if(requestdata('parent'))
569 $_REQUEST['type'] = 'net-comment';
571 $_REQUEST['type'] = 'wall';
573 // set this so that the item_post() function is quiet and doesn't redirect or emit json
575 $_REQUEST['api_source'] = true;
577 // call out normal post function
579 require_once('mod/item.php');
582 // this should output the last post (the one we just posted).
583 return api_status_show($a,$type);
585 api_register_func('api/statuses/update','api_statuses_update', true);
588 function api_status_show(&$a, $type){
589 $user_info = api_get_user($a);
590 // get last public wall message
591 $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`nick` as `reply_author`
592 FROM `item`, `contact`,
593 (SELECT `item`.`id`, `item`.`contact-id`, `contact`.`nick` FROM `item`,`contact` WHERE `contact`.`id`=`item`.`contact-id`) as `i`
594 WHERE `item`.`contact-id` = %d
595 AND `i`.`id` = `item`.`parent`
596 AND `contact`.`id`=`item`.`contact-id` AND `contact`.`self`=1
597 AND `type`!='activity'
598 AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
599 ORDER BY `created` DESC
601 intval($user_info['id'])
604 if (count($lastwall)>0){
605 $lastwall = $lastwall[0];
607 $in_reply_to_status_id = '';
608 $in_reply_to_user_id = '';
609 $in_reply_to_screen_name = '';
610 if ($lastwall['parent']!=$lastwall['id']) {
611 $in_reply_to_status_id=$lastwall['parent'];
612 $in_reply_to_user_id = $lastwall['reply_uid'];
613 $in_reply_to_screen_name = $lastwall['reply_author'];
615 $status_info = array(
616 'text' => html2plain(bbcode($lastwall['body']), 0),
617 'truncated' => false,
618 'created_at' => api_date($lastwall['created']),
619 'in_reply_to_status_id' => $in_reply_to_status_id,
620 'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
621 'id' => $lastwall['contact-id'],
622 'in_reply_to_user_id' => $in_reply_to_user_id,
623 'in_reply_to_screen_name' => $in_reply_to_screen_name,
625 'favorited' => false,
626 'coordinates' => $lastwall['coord'],
627 'place' => $lastwall['location'],
630 $status_info['user'] = $user_info;
632 return api_apply_template("status", $type, array('$status' => $status_info));
641 * Returns extended information of a given user, specified by ID or screen name as per the required id parameter.
642 * The author's most recent status will be returned inline.
643 * http://developer.twitter.com/doc/get/users/show
645 function api_users_show(&$a, $type){
646 $user_info = api_get_user($a);
647 // get last public wall message
648 $lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`nick` as `reply_author`
649 FROM `item`, `contact`,
650 (SELECT `item`.`id`, `item`.`contact-id`, `contact`.`nick` FROM `item`,`contact` WHERE `contact`.`id`=`item`.`contact-id`) as `i`
651 WHERE `item`.`contact-id` = %d
652 AND `i`.`id` = `item`.`parent`
653 AND `contact`.`id`=`item`.`contact-id` AND `contact`.`self`=1
654 AND `type`!='activity'
655 AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
656 ORDER BY `created` DESC
658 intval($user_info['id'])
661 if (count($lastwall)>0){
662 $lastwall = $lastwall[0];
664 $in_reply_to_status_id = '';
665 $in_reply_to_user_id = '';
666 $in_reply_to_screen_name = '';
667 if ($lastwall['parent']!=$lastwall['id']) {
668 $in_reply_to_status_id=$lastwall['parent'];
669 $in_reply_to_user_id = $lastwall['reply_uid'];
670 $in_reply_to_screen_name = $lastwall['reply_author'];
672 $user_info['status'] = array(
673 'created_at' => api_date($lastwall['created']),
674 'id' => $lastwall['contact-id'],
675 'text' => html2plain(bbcode($lastwall['body']), 0),
676 'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
677 'truncated' => false,
678 'in_reply_to_status_id' => $in_reply_to_status_id,
679 'in_reply_to_user_id' => $in_reply_to_user_id,
680 'favorited' => false,
681 'in_reply_to_screen_name' => $in_reply_to_screen_name,
683 'coordinates' => $lastwall['coord'],
684 'place' => $lastwall['location'],
688 return api_apply_template("user", $type, array('$user' => $user_info));
691 api_register_func('api/users/show','api_users_show');
695 * http://developer.twitter.com/doc/get/statuses/home_timeline
697 * TODO: Optional parameters
698 * TODO: Add reply info
700 function api_statuses_home_timeline(&$a, $type){
701 if (local_user()===false) return false;
703 $user_info = api_get_user($a);
704 // get last newtork messages
708 $count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
709 $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
710 if ($page<0) $page=0;
711 $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
712 $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
713 //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
715 $start = $page*$count;
717 //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
720 $sql_extra = 'AND `item`.`id` <= '.intval($max_id);
722 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
723 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
724 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
725 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
726 FROM `item`, `contact`
727 WHERE `item`.`uid` = %d
728 AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
729 AND `contact`.`id` = `item`.`contact-id`
730 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
733 ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
734 intval($user_info['uid']),
736 intval($start), intval($count)
739 $ret = api_format_items($r,$user_info);
742 $data = array('$statuses' => $ret);
746 $data = api_rss_extra($a, $data, $user_info);
749 $as = api_format_as($a, $ret, $user_info);
754 return api_apply_template("timeline", $type, $data);
756 api_register_func('api/statuses/home_timeline','api_statuses_home_timeline', true);
757 api_register_func('api/statuses/friends_timeline','api_statuses_home_timeline', true);
762 function api_statuses_show(&$a, $type){
763 if (local_user()===false) return false;
765 $user_info = api_get_user($a);
768 $id = intval($a->argv[3]);
770 logger('API: api_statuses_show: '.$id);
772 //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
774 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
775 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
776 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
777 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
778 FROM `item`, `contact`
779 WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
780 AND `contact`.`id` = `item`.`contact-id`
781 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
787 $ret = api_format_items($r,$user_info);
789 $data = array('$status' => $ret[0]);
793 $data = api_rss_extra($a, $data, $user_info);
795 return api_apply_template("status", $type, $data);
797 api_register_func('api/statuses/show','api_statuses_show', true);
803 function api_statuses_repeat(&$a, $type){
804 if (local_user()===false) return false;
806 $user_info = api_get_user($a);
809 $id = intval($a->argv[3]);
811 logger('API: api_statuses_repeat: '.$id);
813 //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
815 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
816 `contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
817 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
818 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
819 FROM `item`, `contact`
820 WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
821 AND `contact`.`id` = `item`.`contact-id`
822 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
828 $_REQUEST['body'] = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
829 $_REQUEST['profile_uid'] = local_user();
830 $_REQUEST['type'] = 'wall';
831 $_REQUEST['api_source'] = true;
833 require_once('mod/item.php');
841 return api_apply_template('test', $type, array('$ok' => $ok));
843 api_register_func('api/statuses/retweet','api_statuses_repeat', true);
848 function api_statuses_destroy(&$a, $type){
849 if (local_user()===false) return false;
851 $user_info = api_get_user($a);
854 $id = intval($a->argv[3]);
856 logger('API: api_statuses_destroy: '.$id);
858 require_once('include/items.php');
859 drop_item($id, false);
866 return api_apply_template('test', $type, array('$ok' => $ok));
868 api_register_func('api/statuses/destroy','api_statuses_destroy', true);
872 * http://developer.twitter.com/doc/get/statuses/mentions
875 function api_statuses_mentions(&$a, $type){
876 if (local_user()===false) return false;
878 $user_info = api_get_user($a);
879 // get last newtork messages
883 $count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
884 $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
885 if ($page<0) $page=0;
886 $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
887 $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
888 //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
890 $start = $page*$count;
892 //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
894 $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
895 $myurl = substr($myurl,strpos($myurl,'://')+3);
896 $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
897 $diasp_url = str_replace('/profile/','/u/',$myurl);
898 $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ",
900 dbesc($myurl . '\\]'),
901 dbesc($diasp_url . '\\]')
905 $sql_extra .= ' AND `item`.`id` <= '.intval($max_id);
907 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
908 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
909 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
910 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
911 FROM `item`, `contact`
912 WHERE `item`.`uid` = %d
913 AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
914 AND `contact`.`id` = `item`.`contact-id`
915 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
918 ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
919 intval($user_info['uid']),
921 intval($start), intval($count)
924 $ret = api_format_items($r,$user_info);
927 $data = array('$statuses' => $ret);
931 $data = api_rss_extra($a, $data, $user_info);
934 $as = api_format_as($a, $ret, $user_info);
935 $as["title"] = $a->config['sitename']." Mentions";
940 return api_apply_template("timeline", $type, $data);
942 api_register_func('api/statuses/mentions','api_statuses_mentions', true);
943 api_register_func('api/statuses/replies','api_statuses_mentions', true);
946 function api_statuses_user_timeline(&$a, $type){
947 if (local_user()===false) return false;
949 $user_info = api_get_user($a);
950 // get last newtork messages
953 logger("api_statuses_user_timeline: local_user: ". local_user() .
954 "\nuser_info: ".print_r($user_info, true) .
955 "\n_REQUEST: ".print_r($_REQUEST, true),
959 $count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
960 $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
961 if ($page<0) $page=0;
962 $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
963 //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
965 $start = $page*$count;
967 if ($user_info['self']==1) $sql_extra = "AND `item`.`wall` = 1 ";
969 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
970 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
971 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
972 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
973 FROM `item`, `contact`
974 WHERE `item`.`uid` = %d
975 AND `item`.`contact-id` = %d
976 AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
977 AND `contact`.`id` = `item`.`contact-id`
978 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
981 ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
982 intval(local_user()),
983 intval($user_info['id']),
985 intval($start), intval($count)
988 $ret = api_format_items($r,$user_info);
991 $data = array('$statuses' => $ret);
995 $data = api_rss_extra($a, $data, $user_info);
998 return api_apply_template("timeline", $type, $data);
1001 api_register_func('api/statuses/user_timeline','api_statuses_user_timeline', true);
1004 function api_favorites(&$a, $type){
1005 if (local_user()===false) return false;
1007 $user_info = api_get_user($a);
1008 // in friendica starred item are private
1009 // return favorites only for self
1010 logger('api_favorites: self:' . $user_info['self']);
1012 if ($user_info['self']==0) {
1018 $count = (x($_GET,'count')?$_GET['count']:20);
1019 $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
1020 if ($page<0) $page=0;
1022 $start = $page*$count;
1024 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
1025 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
1026 `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
1027 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
1028 FROM `item`, `contact`
1029 WHERE `item`.`uid` = %d
1030 AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
1031 AND `item`.`starred` = 1
1032 AND `contact`.`id` = `item`.`contact-id`
1033 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
1035 ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
1036 intval($user_info['uid']),
1037 intval($start), intval($count)
1040 $ret = api_format_items($r,$user_info);
1044 $data = array('$statuses' => $ret);
1048 $data = api_rss_extra($a, $data, $user_info);
1051 return api_apply_template("timeline", $type, $data);
1054 api_register_func('api/favorites','api_favorites', true);
1056 function api_format_as($a, $ret, $user_info) {
1059 $as['title'] = $a->config['sitename']." Public Timeline";
1061 foreach ($ret as $item) {
1062 $singleitem["actor"]["displayName"] = $item["user"]["name"];
1063 $singleitem["actor"]["id"] = $item["user"]["contact_url"];
1064 $avatar[0]["url"] = $item["user"]["profile_image_url"];
1065 $avatar[0]["rel"] = "avatar";
1066 $avatar[0]["type"] = "";
1067 $avatar[0]["width"] = 96;
1068 $avatar[0]["height"] = 96;
1069 $avatar[1]["url"] = $item["user"]["profile_image_url"];
1070 $avatar[1]["rel"] = "avatar";
1071 $avatar[1]["type"] = "";
1072 $avatar[1]["width"] = 48;
1073 $avatar[1]["height"] = 48;
1074 $avatar[2]["url"] = $item["user"]["profile_image_url"];
1075 $avatar[2]["rel"] = "avatar";
1076 $avatar[2]["type"] = "";
1077 $avatar[2]["width"] = 24;
1078 $avatar[2]["height"] = 24;
1079 $singleitem["actor"]["avatarLinks"] = $avatar;
1081 $singleitem["actor"]["image"]["url"] = $item["user"]["profile_image_url"];
1082 $singleitem["actor"]["image"]["rel"] = "avatar";
1083 $singleitem["actor"]["image"]["type"] = "";
1084 $singleitem["actor"]["image"]["width"] = 96;
1085 $singleitem["actor"]["image"]["height"] = 96;
1086 $singleitem["actor"]["type"] = "person";
1087 $singleitem["actor"]["url"] = $item["person"]["contact_url"];
1088 $singleitem["actor"]["statusnet:profile_info"]["local_id"] = $item["user"]["id"];
1089 $singleitem["actor"]["statusnet:profile_info"]["following"] = $item["user"]["following"] ? "true" : "false";
1090 $singleitem["actor"]["statusnet:profile_info"]["blocking"] = "false";
1091 $singleitem["actor"]["contact"]["preferredUsername"] = $item["user"]["screen_name"];
1092 $singleitem["actor"]["contact"]["displayName"] = $item["user"]["name"];
1093 $singleitem["actor"]["contact"]["addresses"] = "";
1095 $singleitem["body"] = $item["text"];
1096 $singleitem["object"]["displayName"] = $item["text"];
1097 $singleitem["object"]["id"] = $item["url"];
1098 $singleitem["object"]["type"] = "note";
1099 $singleitem["object"]["url"] = $item["url"];
1100 //$singleitem["context"] =;
1101 $singleitem["postedTime"] = date("c", strtotime($item["published"]));
1102 $singleitem["provider"]["objectType"] = "service";
1103 $singleitem["provider"]["displayName"] = "Test";
1104 $singleitem["provider"]["url"] = "http://test.tld";
1105 $singleitem["title"] = $item["text"];
1106 $singleitem["verb"] = "post";
1107 $singleitem["statusnet:notice_info"]["local_id"] = $item["id"];
1108 $singleitem["statusnet:notice_info"]["source"] = $item["source"];
1109 $singleitem["statusnet:notice_info"]["favorite"] = "false";
1110 $singleitem["statusnet:notice_info"]["repeated"] = "false";
1111 //$singleitem["original"] = $item;
1112 $items[] = $singleitem;
1114 $as['items'] = $items;
1115 $link->url = $a->get_baseurl()."/".$user_info["screen_name"]."/all";
1116 $link->rel = "alternate";
1117 $link->type = "text/html";
1118 $as['link'][] = $link;
1122 function api_format_items($r,$user_info) {
1124 //logger('api_format_items: ' . print_r($r,true));
1126 //logger('api_format_items: ' . print_r($user_info,true));
1131 foreach($r as $item) {
1132 localize_item($item);
1133 $status_user = (($item['cid']==$user_info['id'])?$user_info: api_item_get_user($a,$item));
1135 if ($item['parent']!=$item['id']) {
1136 $r = q("select id from item where parent=%s and id<%s order by id desc limit 1",
1137 intval($item['parent']), intval($item['id']));
1139 $in_reply_to_status_id = $r[0]['id'];
1141 $in_reply_to_status_id = $item['parent'];
1143 $r = q("select `item`.`contact-id`, `contact`.nick, `item`.`author-name` from item, contact
1144 where `contact`.`id` = `item`.`contact-id` and `item`.id=%d", intval($in_reply_to_status_id));
1146 $in_reply_to_screen_name = $r[0]['author-name'];
1147 $in_reply_to_user_id = $r[0]['contact-id'];
1150 $in_reply_to_screen_name = '';
1151 $in_reply_to_user_id = 0;
1152 $in_reply_to_status_id = 0;
1156 'text' => trim($item['title']." \n".html2plain(bbcode($item['body']), 0)),
1157 'truncated' => False,
1158 'created_at'=> api_date($item['created']),
1159 'in_reply_to_status_id' => $in_reply_to_status_id,
1160 'source' => (($item['app']) ? $item['app'] : 'web'),
1161 'id' => intval($item['id']),
1162 'in_reply_to_user_id' => $in_reply_to_user_id,
1163 'in_reply_to_screen_name' => $in_reply_to_screen_name,
1165 'favorited' => $item['starred'] ? true : false,
1166 'user' => $status_user ,
1167 'statusnet_html' => bbcode($item['body']),
1168 'statusnet_conversation_id' => 0,
1171 // Seesmic doesn't like the following content
1172 if ($_SERVER['HTTP_USER_AGENT'] != 'Seesmic') {
1174 'updated' => api_date($item['edited']),
1175 'published' => api_date($item['created']),
1176 'message_id' => $item['uri'],
1177 'url' => ($item['plink']!=''?$item['plink']:$item['author-link']),
1178 'coordinates' => $item['coord'],
1179 'place' => $item['location'],
1180 'contributors' => '',
1181 'annotations' => '',
1183 'objecttype' => (($item['object-type']) ? $item['object-type'] : ACTIVITY_OBJ_NOTE),
1184 'verb' => (($item['verb']) ? $item['verb'] : ACTIVITY_POST),
1185 'self' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
1186 'edit' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
1189 $status = array_merge($status, $status2);
1198 function api_account_rate_limit_status(&$a,$type) {
1201 'reset_time_in_seconds' => strtotime('now + 1 hour'),
1202 'remaining_hits' => (string) 150,
1203 'hourly_limit' => (string) 150,
1204 'reset_time' => datetime_convert('UTC','UTC','now + 1 hour',ATOM_TIME),
1207 $hash['resettime_in_seconds'] = $hash['reset_time_in_seconds'];
1209 return api_apply_template('ratelimit', $type, array('$hash' => $hash));
1212 api_register_func('api/account/rate_limit_status','api_account_rate_limit_status',true);
1214 function api_help_test(&$a,$type) {
1221 return api_apply_template('test', $type, array('$ok' => $ok));
1224 api_register_func('api/help/test','api_help_test',true);
1227 * https://dev.twitter.com/docs/api/1/get/statuses/friends
1228 * This function is deprecated by Twitter
1229 * returns: json, xml
1231 function api_statuses_f(&$a, $type, $qtype) {
1232 if (local_user()===false) return false;
1233 $user_info = api_get_user($a);
1236 // friends and followers only for self
1237 if ($user_info['self']==0){
1241 if (x($_GET,'cursor') && $_GET['cursor']=='undefined'){
1242 /* this is to stop Hotot to load friends multiple times
1243 * I'm not sure if I'm missing return something or
1244 * is a bug in hotot. Workaround, meantime
1248 return array('$users' => $ret);*/
1252 if($qtype == 'friends')
1253 $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
1254 if($qtype == 'followers')
1255 $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
1257 $r = q("SELECT id FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra",
1258 intval(local_user())
1262 foreach($r as $cid){
1263 $ret[] = api_get_user($a, $cid['id']);
1267 return array('$users' => $ret);
1270 function api_statuses_friends(&$a, $type){
1271 $data = api_statuses_f($a,$type,"friends");
1272 if ($data===false) return false;
1273 return api_apply_template("friends", $type, $data);
1275 function api_statuses_followers(&$a, $type){
1276 $data = api_statuses_f($a,$type,"followers");
1277 if ($data===false) return false;
1278 return api_apply_template("friends", $type, $data);
1280 api_register_func('api/statuses/friends','api_statuses_friends',true);
1281 api_register_func('api/statuses/followers','api_statuses_followers',true);
1288 function api_statusnet_config(&$a,$type) {
1289 $name = $a->config['sitename'];
1290 $server = $a->get_hostname();
1291 $logo = $a->get_baseurl() . '/images/friendica-64.png';
1292 $email = $a->config['admin_email'];
1293 $closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
1294 $private = (($a->config['system']['block_public']) ? 'true' : 'false');
1295 $textlimit = (string) (($a->config['max_import_size']) ? $a->config['max_import_size'] : 200000);
1296 if($a->config['api_import_size'])
1297 $texlimit = string($a->config['api_import_size']);
1298 $ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false');
1299 $sslserver = (($ssl === 'true') ? str_replace('http:','https:',$a->get_baseurl()) : '');
1302 'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
1303 'logo' => $logo, 'fancy' => 'true', 'language' => 'en', 'email' => $email, 'broughtby' => '',
1304 'broughtbyurl' => '', 'timezone' => 'UTC', 'closed' => $closed, 'inviteonly' => 'false',
1305 'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl,
1306 'shorturllength' => '30'
1310 return api_apply_template('config', $type, array('$config' => $config));
1313 api_register_func('api/statusnet/config','api_statusnet_config',false);
1315 function api_statusnet_version(&$a,$type) {
1319 if($type === 'xml') {
1320 header("Content-type: application/xml");
1321 echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<version>0.9.7</version>' . "\r\n";
1324 elseif($type === 'json') {
1325 header("Content-type: application/json");
1330 api_register_func('api/statusnet/version','api_statusnet_version',false);
1333 function api_ff_ids(&$a,$type,$qtype) {
1337 if($qtype == 'friends')
1338 $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND));
1339 if($qtype == 'followers')
1340 $sql_extra = sprintf(" AND ( `rel` = %d OR `rel` = %d ) ", intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND));
1343 $r = q("SELECT id FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 $sql_extra",
1344 intval(local_user())
1348 if($type === 'xml') {
1349 header("Content-type: application/xml");
1350 echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<ids>' . "\r\n";
1352 echo '<id>' . $rr['id'] . '</id>' . "\r\n";
1353 echo '</ids>' . "\r\n";
1356 elseif($type === 'json') {
1358 header("Content-type: application/json");
1359 foreach($r as $rr) $ret[] = $rr['id'];
1360 echo json_encode($ret);
1366 function api_friends_ids(&$a,$type) {
1367 api_ff_ids($a,$type,'friends');
1369 function api_followers_ids(&$a,$type) {
1370 api_ff_ids($a,$type,'followers');
1372 api_register_func('api/friends/ids','api_friends_ids',true);
1373 api_register_func('api/followers/ids','api_followers_ids',true);
1376 function api_direct_messages_new(&$a, $type) {
1377 if (local_user()===false) return false;
1379 if (!x($_POST, "text") || !x($_POST,"screen_name")) return;
1381 $sender = api_get_user($a);
1383 $r = q("SELECT `id` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
1384 intval(local_user()),
1385 dbesc($_POST['screen_name']));
1387 $recipient = api_get_user($a, $r[0]['id']);
1390 require_once("include/message.php");
1391 $sub = ( (strlen($_POST['text'])>10)?substr($_POST['text'],0,10)."...":$_POST['text']);
1392 $id = send_message($recipient['id'], $_POST['text'], $sub);
1396 $r = q("SELECT * FROM `mail` WHERE id=%d", intval($id));
1399 'id' => $item['id'],
1400 'created_at'=> api_date($item['created']),
1401 'sender_id'=> $sender['id'] ,
1402 'sender_screen_name'=> $sender['screen_name'],
1404 'recipient_id'=> $recipient['id'],
1405 'recipient_screen_name'=> $recipient['screen_name'],
1406 'recipient'=> $recipient,
1408 'text'=> $item['title']."\n".html2plain(bbcode($item['body']), 0) ,
1413 $ret = array("error"=>$id);
1416 $data = Array('$messages'=>$ret);
1421 $data = api_rss_extra($a, $data, $user_info);
1424 return api_apply_template("direct_messages", $type, $data);
1427 api_register_func('api/direct_messages/new','api_direct_messages_new',true);
1429 function api_direct_messages_box(&$a, $type, $box) {
1430 if (local_user()===false) return false;
1432 $user_info = api_get_user($a);
1435 $count = (x($_GET,'count')?$_GET['count']:20);
1436 $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
1437 if ($page<0) $page=0;
1439 $start = $page*$count;
1442 if ($box=="sentbox") {
1443 $sql_extra = "`from-url`='%s'";
1445 $sql_extra = "`from-url`!='%s'";
1448 $r = q("SELECT * FROM `mail` WHERE uid=%d AND $sql_extra ORDER BY created DESC LIMIT %d,%d",
1449 intval(local_user()),
1450 dbesc( $a->get_baseurl() . '/profile/' . $a->user['nickname'] ),
1451 intval($start), intval($count)
1455 foreach($r as $item){
1458 $recipient = $user_info;
1459 $sender = api_get_user($a,$item['contact-id']);
1462 $recipient = api_get_user($a,$item['contact-id']);
1463 $sender = $user_info;
1468 'id' => $item['id'],
1469 'created_at'=> api_date($item['created']),
1470 'sender_id'=> $sender['id'] ,
1471 'sender_screen_name'=> $sender['screen_name'],
1473 'recipient_id'=> $recipient['id'],
1474 'recipient_screen_name'=> $recipient['screen_name'],
1475 'recipient'=> $recipient,
1477 'text'=> $item['title']."\n".html2plain(bbcode($item['body']), 0) ,
1484 $data = array('$messages' => $ret);
1488 $data = api_rss_extra($a, $data, $user_info);
1491 return api_apply_template("direct_messages", $type, $data);
1495 function api_direct_messages_sentbox(&$a, $type){
1496 return api_direct_messages_box($a, $type, "sentbox");
1498 function api_direct_messages_inbox(&$a, $type){
1499 return api_direct_messages_box($a, $type, "inbox");
1501 api_register_func('api/direct_messages/sent','api_direct_messages_sentbox',true);
1502 api_register_func('api/direct_messages','api_direct_messages_inbox',true);
1506 function api_oauth_request_token(&$a, $type){
1508 $oauth = new FKOAuth1();
1509 $r = $oauth->fetch_request_token(OAuthRequest::from_request());
1510 }catch(Exception $e){
1511 echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
1516 function api_oauth_access_token(&$a, $type){
1518 $oauth = new FKOAuth1();
1519 $r = $oauth->fetch_access_token(OAuthRequest::from_request());
1520 }catch(Exception $e){
1521 echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme();
1527 api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
1528 api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
1531 Not implemented by now:
1535 statuses/public_timeline
1536 statuses/retweets_of_me
1541 account/update_location
1542 account/update_profile_background_image
1543 account/update_profile_image
1548 Not implemented in status.net:
1549 statuses/retweeted_to_me
1550 statuses/retweeted_by_me
1551 direct_messages/destroy
1553 account/update_delivery_device
1554 notifications/follow