]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
basic file upload/attach
[friendica.git] / include / api.php
index c2a9b3bbe084b62dcb51acca4c9d3a576376bff5..84cb7b38f623e70e9a7f6a6f8273d230ddbc5965 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,
                        case "atom":
                        case "xml":
                                $data = api_xmlify($data);
-                               $tpl = load_view_file("view/api_".$templatename."_".$type.".tpl");
+                               $tpl = get_markup_template("api_".$templatename."_".$type.".tpl");
                                $ret = replace_macros($tpl, $data);
                                break;
                        case "json":
                                '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
+