]> git.mxchange.org Git - friendica.git/blobdiff - mod/api.php
Merge pull request #3397 from tobiasd/20170427-robots
[friendica.git] / mod / api.php
index 67564836e8386b6a58abadc2d4fd51999fe5edbe..3916636cfd32f02bbdbdbfa1d28d4a1251db792a 100644 (file)
@@ -1,8 +1,10 @@
 <?php
+
 require_once('include/api.php');
 
-if(! function_exists('oauth_get_client')) {
 function oauth_get_client($request){
+
+
        $params = $request->get_parameters();
        $token = $params['oauth_token'];
 
@@ -12,16 +14,15 @@ function oauth_get_client($request){
                        AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'",
                        dbesc($token));
 
-       if (!count($r))
+       if (!dbm::is_result($r))
                return null;
 
        return $r[0];
 }
-}
 
-if(! function_exists('api_post')) {
-function api_post(&$a) {
-       if(! local_user()) {
+function api_post(App $a) {
+
+       if (! local_user()) {
                notice( t('Permission denied.') . EOL);
                return;
        }
@@ -30,11 +31,10 @@ function api_post(&$a) {
                notice( t('Permission denied.') . EOL);
                return;
        }
-}
+
 }
 
-if(! function_exists('api_content')) {
-function api_content(&$a) {
+function api_content(App $a) {
        if ($a->cmd=='api/oauth/authorize'){
                /*
                 * api/oauth/authorize interact with the user. return a standard page
@@ -84,7 +84,7 @@ function api_content(&$a) {
                }
 
 
-               if(! local_user()) {
+               if (! local_user()) {
                        /// @TODO We need login form to redirect to this page
                        notice( t('Please login to continue.') . EOL );
                        return login(false,$request->get_parameters());
@@ -114,4 +114,3 @@ function api_content(&$a) {
        echo api_call($a);
        killme();
 }
-}