From 976d1eaf4312f8c45af0e16205f573afc5be5136 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Wed, 27 Apr 2011 17:46:23 +0200 Subject: [PATCH] API work --- include/api.php | 28 ++++++++++++++---- view/api_timeline_atom.tpl | 58 +++++++++++++++++++++++++------------- view/api_timeline_rss.tpl | 44 ++++++++++++++--------------- 3 files changed, 81 insertions(+), 49 deletions(-) diff --git a/include/api.php b/include/api.php index c2a9b3bbe..82790a638 100644 --- a/include/api.php +++ b/include/api.php @@ -49,8 +49,13 @@ dbesc(trim($user)), dbesc($encrypted) ); - if(count($r)) + if(count($r)){ $record = $r[0]; + } else { + header('WWW-Authenticate: Basic realm="Friendika"'); + header('HTTP/1.0 401 Unauthorized'); + die('This api require login'); + } $_SESSION['uid'] = $record['uid']; $_SESSION['theme'] = $record['theme']; $_SESSION['authenticated'] = 1; @@ -90,6 +95,7 @@ GLOBAL $API; foreach ($API as $p=>$info){ if (strpos($a->query_string, $p)===0){ + #unset($_SERVER['PHP_AUTH_USER']); if ($info['auth']===true && local_user()===false) { api_login($a); } @@ -139,6 +145,7 @@ 'self' => $a->get_baseurl(). "/". $a->query_string, 'updated' => api_date(null), 'language' => $user_info['language'], + 'logo' => $a->get_baseurl()."/images/friendika-32.png", ); return $arr; @@ -214,7 +221,7 @@ 'name' => $uinfo[0]['username'], 'screen_name' => $uinfo[0]['nickname'], 'location' => $uinfo[0]['default-location'], - 'profile_image_url' => $uinfo[0]['photo'], + 'profile_image_url' => $uinfo[0]['micro'], 'url' => $uinfo[0]['url'], 'protected' => false, # 'friends_count' => $countfriends, @@ -385,6 +392,7 @@ 'created_at'=> api_date($item['created']), 'id' => $item['id'], 'text' => strip_tags(bbcode($item['body'])), + 'html' => bbcode($item['body']), 'source' => 'web', 'url' => ($item['plink']!=''?$item['plink']:$item['author-link']), 'truncated' => False, @@ -398,18 +406,26 @@ 'contributors' => '', 'annotations' => '', 'entities' => '', - 'user' => $user_info + 'user' => $user_info, + 'objecttype' => $item['object-type'], + 'verb' => $item['verb'], + 'self' => $a->get_baseurl()."/api/statuses/show/".$ite['id'].".".$type, + 'edit' => $a->get_baseurl()."/api/statuses/show/".$ite['id'].".".$type, ); $ret[]=$status; }; $data = array('$statuses' => $ret); - if ($type=="rss" || $type=="atom") $data = api_rss_extra($a, $data, $user_info); - + switch($type){ + case "atom": + case "rss": + $data = api_rss_extra($a, $data, $user_info); + } + return api_apply_template("timeline", $type, $data); } api_register_func('api/statuses/home_timeline','api_statuses_home_timeline', true); api_register_func('api/statuses/friends_timeline','api_statuses_home_timeline', true); api_register_func('api/statuses/user_timeline','api_statuses_home_timeline', true); # TODO: user_timeline should be profile view - \ No newline at end of file + diff --git a/view/api_timeline_atom.tpl b/view/api_timeline_atom.tpl index 63782ce36..069ff7651 100644 --- a/view/api_timeline_atom.tpl +++ b/view/api_timeline_atom.tpl @@ -1,21 +1,39 @@ - - - Friendika - $rss.alternate - - Friendika timeline - $rss.language - 40 + + StatusNet + tag:friendika:PublicTimeline + Network on Friendika + Your network updates on Friendika + $rss.logo + $rss.updated + + + {{ for $statuses as $status }} + + $status.objecttype + $status.id + $status.text + $status.html + + $status.verb + $status.created_at + $status.created_at -{{ for $statuses as $status }} - - $status.text - $status.text - $status.created_at - $status.url - $status.url - $status.source - -{{ endfor }} - - \ No newline at end of file + + + + + + + + {{ endfor }} + diff --git a/view/api_timeline_rss.tpl b/view/api_timeline_rss.tpl index d07ac42ad..fbba93ee9 100644 --- a/view/api_timeline_rss.tpl +++ b/view/api_timeline_rss.tpl @@ -1,23 +1,21 @@ - - Friendika - tag:friendika:Status - - - $rss.updated - Friendika timeline - {{ for $statuses as $status }} - - $status.text - $status.text - $status.id - $status.created_at - $status.created_at - - - $status.user.name - $status.user.url - - $status.source - - {{ endfor }} - \ No newline at end of file + + + Friendika + $rss.alternate + + Friendika timeline + $rss.language + 40 + +{{ for $statuses as $status }} + + $status.text + $status.text + $status.created_at + $status.url + $status.url + $status.source + +{{ endfor }} + +