]> git.mxchange.org Git - friendica.git/blobdiff - mod/api.php
Indentation fix
[friendica.git] / mod / api.php
index 67564836e8386b6a58abadc2d4fd51999fe5edbe..cda97c729ce9bb5bfc80c622ede8530de4387938 100644 (file)
@@ -1,8 +1,14 @@
 <?php
+
+use Friendica\App;
+use Friendica\Core\Config;
+use Friendica\Database\DBM;
+
 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 +18,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 +35,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
@@ -58,7 +62,7 @@ function api_content(&$a) {
                        $consumer = new OAuthConsumer($app['client_id'], $app['pw'], $app['redirect_uri']);
 
                        $verifier = md5($app['secret'].local_user());
-                       set_config("oauth", $verifier, local_user());
+                       Config::set("oauth", $verifier, local_user());
 
 
                        if ($consumer->callback_url!=null) {
@@ -84,7 +88,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());
@@ -106,12 +110,9 @@ function api_content(&$a) {
                        '$no'   => t('No'),
                ));
 
-               //echo "<pre>"; var_dump($app); killme();
-
                return $o;
        }
 
        echo api_call($a);
        killme();
 }
-}