]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Fix searching for contacts
[friendica.git] / include / api.php
index 698fa2f995766722e4d556a1cc57c6ea9ab3125f..0fab1f47c164e02a64e944494827ae2c6d8467c5 100644 (file)
@@ -11,7 +11,6 @@ use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
-use Friendica\Core\Authentication;
 use Friendica\Core\Config;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
@@ -19,6 +18,7 @@ use Friendica\Core\Logger;
 use Friendica\Core\NotificationsManager;
 use Friendica\Core\PConfig;
 use Friendica\Core\Protocol;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -250,7 +250,7 @@ function api_login(App $a)
                throw new UnauthorizedException("This API requires login");
        }
 
-       Authentication::setAuthenticatedSessionForUser($record);
+       Session::setAuthenticatedForUser($a, $record);
 
        $_SESSION["allow_api"] = true;
 
@@ -361,10 +361,10 @@ function api_call(App $a)
                        }
                }
 
-               Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call']);
+               Logger::warning(API_LOG_PREFIX . 'not implemented', ['module' => 'api', 'action' => 'call', 'query' => $a->query_string]);
                throw new NotImplementedException();
        } catch (HTTPException $e) {
-               header("HTTP/1.1 {$e->httpcode} {$e->httpdesc}");
+               header("HTTP/1.1 {$e->getCode()} {$e->httpdesc}");
                return api_error($type, $e);
        }
 }
@@ -384,7 +384,7 @@ function api_error($type, $e)
        /// @TODO:  https://dev.twitter.com/overview/api/response-codes
 
        $error = ["error" => $error,
-                       "code" => $e->httpcode . " " . $e->httpdesc,
+                       "code" => $e->getCode() . " " . $e->httpdesc,
                        "request" => $a->query_string];
 
        $return = api_format_data('status', $type, ['status' => $error]);
@@ -611,7 +611,7 @@ function api_get_user(App $a, $contact_id = null)
                                'name' => $contact["name"],
                                'screen_name' => (($contact['nick']) ? $contact['nick'] : $contact['name']),
                                'location' => ($contact["location"] != "") ? $contact["location"] : ContactSelector::networkToName($contact['network'], $contact['url']),
-                               'description' => $contact["about"],
+                               'description' => HTML::toPlaintext(BBCode::toPlaintext($contact["about"])),
                                'profile_image_url' => $contact["micro"],
                                'profile_image_url_https' => $contact["micro"],
                                'profile_image_url_profile_size' => $contact["thumb"],
@@ -690,7 +690,7 @@ function api_get_user(App $a, $contact_id = null)
                'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
                'screen_name' => (($uinfo[0]['nick']) ? $uinfo[0]['nick'] : $uinfo[0]['name']),
                'location' => $location,
-               'description' => $description,
+               'description' => HTML::toPlaintext(BBCode::toPlaintext($description)),
                'profile_image_url' => $uinfo[0]['micro'],
                'profile_image_url_https' => $uinfo[0]['micro'],
                'profile_image_url_profile_size' => $uinfo[0]["thumb"],
@@ -1271,7 +1271,7 @@ function api_status_show($type, $item_id)
 function api_get_last_status($ownerId, $uid)
 {
        $condition = [
-               'owner-id' => $ownerId,
+               'author-id'=> $ownerId,
                'uid'      => $uid,
                'gravity'  => [GRAVITY_PARENT, GRAVITY_COMMENT],
                'private'  => false