This commit is contained in:
fabrixxm 2011-04-27 17:46:23 +02:00
parent 41f6ccc039
commit 976d1eaf43
3 changed files with 81 additions and 49 deletions

View File

@ -49,8 +49,13 @@
dbesc(trim($user)), dbesc(trim($user)),
dbesc($encrypted) dbesc($encrypted)
); );
if(count($r)) if(count($r)){
$record = $r[0]; $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['uid'] = $record['uid'];
$_SESSION['theme'] = $record['theme']; $_SESSION['theme'] = $record['theme'];
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
@ -90,6 +95,7 @@
GLOBAL $API; GLOBAL $API;
foreach ($API as $p=>$info){ foreach ($API as $p=>$info){
if (strpos($a->query_string, $p)===0){ if (strpos($a->query_string, $p)===0){
#unset($_SERVER['PHP_AUTH_USER']);
if ($info['auth']===true && local_user()===false) { if ($info['auth']===true && local_user()===false) {
api_login($a); api_login($a);
} }
@ -139,6 +145,7 @@
'self' => $a->get_baseurl(). "/". $a->query_string, 'self' => $a->get_baseurl(). "/". $a->query_string,
'updated' => api_date(null), 'updated' => api_date(null),
'language' => $user_info['language'], 'language' => $user_info['language'],
'logo' => $a->get_baseurl()."/images/friendika-32.png",
); );
return $arr; return $arr;
@ -214,7 +221,7 @@
'name' => $uinfo[0]['username'], 'name' => $uinfo[0]['username'],
'screen_name' => $uinfo[0]['nickname'], 'screen_name' => $uinfo[0]['nickname'],
'location' => $uinfo[0]['default-location'], 'location' => $uinfo[0]['default-location'],
'profile_image_url' => $uinfo[0]['photo'], 'profile_image_url' => $uinfo[0]['micro'],
'url' => $uinfo[0]['url'], 'url' => $uinfo[0]['url'],
'protected' => false, # 'protected' => false, #
'friends_count' => $countfriends, 'friends_count' => $countfriends,
@ -385,6 +392,7 @@
'created_at'=> api_date($item['created']), 'created_at'=> api_date($item['created']),
'id' => $item['id'], 'id' => $item['id'],
'text' => strip_tags(bbcode($item['body'])), 'text' => strip_tags(bbcode($item['body'])),
'html' => bbcode($item['body']),
'source' => 'web', 'source' => 'web',
'url' => ($item['plink']!=''?$item['plink']:$item['author-link']), 'url' => ($item['plink']!=''?$item['plink']:$item['author-link']),
'truncated' => False, 'truncated' => False,
@ -398,18 +406,26 @@
'contributors' => '', 'contributors' => '',
'annotations' => '', 'annotations' => '',
'entities' => '', '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; $ret[]=$status;
}; };
$data = array('$statuses' => $ret); $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); return api_apply_template("timeline", $type, $data);
} }
api_register_func('api/statuses/home_timeline','api_statuses_home_timeline', true); 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/friends_timeline','api_statuses_home_timeline', true);
api_register_func('api/statuses/user_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 # TODO: user_timeline should be profile view

View File

@ -1,21 +1,39 @@
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:georss="http://www.georss.org/georss" xmlns:twitter="http://api.twitter.com"> <feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:statusnet="http://status.net/schema/api/1/">
<channel> <generator uri="http://status.net" version="0.9.7">StatusNet</generator>
<title>Friendika</title> <id>tag:friendika:PublicTimeline</id>
<link>$rss.alternate</link> <title>Network on Friendika</title>
<atom:link type="application/rss+xml" rel="self" href="$rss.self"/> <subtitle>Your network updates on Friendika</subtitle>
<description>Friendika timeline</description> <logo>$rss.logo</logo>
<language>$rss.language</language> <updated>$rss.updated</updated>
<ttl>40</ttl> <link type="text/html" rel="alternate" href="$rss.alternate"/>
<link type="application/atom+xml" rel="self" href="$rss.self"/>
{{ for $statuses as $status }}
<entry>
<activity:object-type>$status.objecttype</activity:object-type>
<id>$status.id</id>
<title>$status.text</title>
<content type="html">$status.html</content>
<link rel="alternate" type="text/html" href="$status.url"/>
<activity:verb>$status.verb</activity:verb>
<published>$status.created_at</published>
<updated>$status.created_at</updated>
{{ for $statuses as $status }} <link rel="ostatus:conversation" href="$status.url"/>
<item> <!--
<title>$status.text</title> <source>
<description>$status.text</description> <id>http://identi.ca/api/statuses/user_timeline/397830.atom</id>
<pubDate>$status.created_at</pubDate> <title>Sin Mobopolitan</title>
<guid>$status.url</guid> <link rel="alternate" type="text/html" href="http://identi.ca/mobopolitan"/>
<link>$status.url</link> <link rel="self" type="application/atom+xml" href="http://identi.ca/api/statuses/user_timeline/397830.atom"/>
<twitter:source>$status.source</twitter:source> <link rel="license" href="http://creativecommons.org/licenses/by/3.0/"/>
</item> <icon>http://avatar.identi.ca/397830-96-20110312195623.jpeg</icon>
{{ endfor }} <updated>2011-04-21T18:39:32+00:00</updated>
</channel> </source>
</rss> -->
<link rel="self" type="application/atom+xml" href="$status.self"/>
<link rel="edit" type="application/atom+xml" href="$status.edit"/>
<statusnet:notice_info local_id="$status.id" source="$status.source" favorite="false" repeated="false">
</statusnet:notice_info>
</entry>
{{ endfor }}
</feed>

View File

@ -1,23 +1,21 @@
<feed xml:lang="en-US" xmlns:georss="http://www.georss.org/georss" xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com"> <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:georss="http://www.georss.org/georss" xmlns:twitter="http://api.twitter.com">
<title>Friendika</title> <channel>
<id>tag:friendika:Status</id> <title>Friendika</title>
<link type="text/html" rel="alternate" href="$rss.alternate"/> <link>$rss.alternate</link>
<link type="application/atom+xml" rel="self" href="$rss.self"/> <atom:link type="application/rss+xml" rel="self" href="$rss.self"/>
<updated>$rss.updated</updated> <description>Friendika timeline</description>
<subtitle>Friendika timeline</subtitle> <language>$rss.language</language>
{{ for $statuses as $status }} <ttl>40</ttl>
<entry>
<title>$status.text</title> {{ for $statuses as $status }}
<content type="html">$status.text</content> <item>
<id>$status.id</id> <title>$status.text</title>
<published>$status.created_at</published> <description>$status.text</description>
<updated>$status.created_at</updated> <pubDate>$status.created_at</pubDate>
<link type="text/html" rel="alternate" href="$status.url"/> <guid>$status.url</guid>
<author> <link>$status.url</link>
<name>$status.user.name</name> <twitter:source>$status.source</twitter:source>
<uri>$status.user.url</uri> </item>
</author> {{ endfor }}
<twitter:source>$status.source</twitter:source> </channel>
</entry> </rss>
{{ endfor }}
</feed>