]> git.mxchange.org Git - friendica.git/commitdiff
API work
authorfabrixxm <fabrix.xm@gmail.com>
Wed, 27 Apr 2011 15:46:23 +0000 (17:46 +0200)
committerfabrixxm <fabrix.xm@gmail.com>
Wed, 27 Apr 2011 15:46:23 +0000 (17:46 +0200)
include/api.php
view/api_timeline_atom.tpl
view/api_timeline_rss.tpl

index c2a9b3bbe084b62dcb51acca4c9d3a576376bff5..82790a6383f8a329bbe2cd7caed36416c8b811cf 100644 (file)
                        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);
                                }
                        '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;
                        '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,
                                '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,
                                '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
+       
index 63782ce36f09c454478c174e531f6d2bc3052a35..069ff7651e840afb0f34245b070a3e7d5a16433d 100644 (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">
-  <channel>
-    <title>Friendika</title>
-    <link>$rss.alternate</link>
-    <atom:link type="application/rss+xml" rel="self" href="$rss.self"/>
-    <description>Friendika timeline</description>
-    <language>$rss.language</language>
-    <ttl>40</ttl>
+<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/">
+ <generator uri="http://status.net" version="0.9.7">StatusNet</generator>
+ <id>tag:friendika:PublicTimeline</id>
+ <title>Network on Friendika</title>
+ <subtitle>Your network updates on Friendika</subtitle>
+ <logo>$rss.logo</logo>
+ <updated>$rss.updated</updated>
+ <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 }}
-  <item>
-    <title>$status.text</title>
-    <description>$status.text</description>
-    <pubDate>$status.created_at</pubDate>
-    <guid>$status.url</guid>
-    <link>$status.url</link>
-    <twitter:source>$status.source</twitter:source>
-  </item>
-{{ endfor }}
-  </channel>
-</rss>
\ No newline at end of file
+        <link rel="ostatus:conversation" href="$status.url"/>
+        <!--
+        <source>
+         <id>http://identi.ca/api/statuses/user_timeline/397830.atom</id>
+         <title>Sin Mobopolitan</title>
+         <link rel="alternate" type="text/html" href="http://identi.ca/mobopolitan"/>
+         <link rel="self" type="application/atom+xml" href="http://identi.ca/api/statuses/user_timeline/397830.atom"/>
+         <link rel="license" href="http://creativecommons.org/licenses/by/3.0/"/>
+         <icon>http://avatar.identi.ca/397830-96-20110312195623.jpeg</icon>
+         <updated>2011-04-21T18:39:32+00:00</updated>
+        </source>
+        -->
+        <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>
index d07ac42ad5fb89be3e3a6f35dc20df3f576ed497..fbba93ee9013fbc2b8b45f61b9c74dbbd1ee179b 100644 (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">
-  <title>Friendika</title>
-  <id>tag:friendika:Status</id>
-  <link type="text/html" rel="alternate" href="$rss.alternate"/>
-  <link type="application/atom+xml" rel="self" href="$rss.self"/>
-  <updated>$rss.updated</updated>
-  <subtitle>Friendika timeline</subtitle>
-       {{ for $statuses as $status }}
-    <entry>
-      <title>$status.text</title>
-      <content type="html">$status.text</content>
-      <id>$status.id</id>
-      <published>$status.created_at</published>
-      <updated>$status.created_at</updated>
-      <link type="text/html" rel="alternate" href="$status.url"/>
-      <author>
-        <name>$status.user.name</name>
-        <uri>$status.user.url</uri>
-      </author>
-      <twitter:source>$status.source</twitter:source>
-    </entry>
-    {{ endfor }}
-</feed>
\ No newline at end of file
+<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">
+  <channel>
+    <title>Friendika</title>
+    <link>$rss.alternate</link>
+    <atom:link type="application/rss+xml" rel="self" href="$rss.self"/>
+    <description>Friendika timeline</description>
+    <language>$rss.language</language>
+    <ttl>40</ttl>
+
+{{ for $statuses as $status }}
+  <item>
+    <title>$status.text</title>
+    <description>$status.text</description>
+    <pubDate>$status.created_at</pubDate>
+    <guid>$status.url</guid>
+    <link>$status.url</link>
+    <twitter:source>$status.source</twitter:source>
+  </item>
+{{ endfor }}
+  </channel>
+</rss>