Ignore:
Timestamp:
04/05/12 17:00:04 (12 years ago)
Author:
cristiano
Message:

Ticket #2598 - implementação base REST + oauth

Location:
sandbox/2.4-expresso-api
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.4-expresso-api

    • Property svn:ignore
      •  

        old new  
        22header.inc.php 
        33._header.inc.php 
         4.htaccess.swp 
  • sandbox/2.4-expresso-api/phpgwapi/templates/default/login_default.php

    r5281 r5888  
    177177                        else 
    178178                                $_POST['login'] = $_POST['user']; 
     179 
     180                        /** 
     181                         * LOGIN OAUTH POR CURL 
     182                         */ 
     183                        $ch = curl_init(); 
     184 
     185                        $param  = 'grant_type=password'; 
     186                        $param .= '&client_id=' . $GLOBALS['oauth']['client_id']; 
     187                        $param .= '&client_secret=' . $GLOBALS['oauth']['client_secret']; 
     188                        $param .= '&username=' . $_POST['user']; 
     189                        $param .= '&password=' . $_POST['passwd']; 
     190 
     191                        // set URL and other appropriate options 
     192                        curl_setopt($ch, CURLOPT_URL, $GLOBALS['oauth']['url_token']); 
     193                        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*')); 
     194                        curl_setopt($ch, CURLOPT_POST, TRUE); 
     195                        curl_setopt($ch, CURLOPT_POSTFIELDS, $param); 
     196                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  //configura para nao imprimir a saida na tela 
     197                        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);//Passe um nï¿œmero long como parï¿œmetro que contï¿œm o limite de tempo, em segundos, que vocï¿œ permite as funᅵᅵes CURL levar.  
     198 
     199                        // grab URL and pass it to the browser 
     200                        $res = curl_exec($ch); 
     201                         
     202                        // close cURL resource, and free up system resources 
     203                        curl_close($ch); 
     204                        $a = json_decode($res); 
     205         
     206                        if ( isset($a->access_token) ) { 
     207                                $_SESSION['oauth']['access_token'] = $a->access_token; 
     208                                $_SESSION['oauth']['expires_in'] = $a->expires_in; 
     209                                $_SESSION['oauth']['token_type'] = $a->token_type; 
     210                                $_SESSION['oauth']['scope'] = $a->scope; 
     211                                $_SESSION['oauth']['refresh_token'] = $a->refresh_token; 
     212                                 
     213                                 
     214                        } 
     215                        else { 
     216                        } 
     217                        /** 
     218                         * #################### 
     219                         */ 
     220 
    179221                } 
    180222                if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' && 
     
    598640        if(isset($ultima_revisao)) $tmpl->set_var('ultima_rev','<br>' . $ultima_revisao); 
    599641 
    600         // Adiciona código personalizado de outro template 
     642        // Adiciona cï¿œdigo personalizado de outro template 
    601643        // que esteja utilizando o login_default.php 
    602644        if(is_file('.'.$template_dir.'/login.inc.php')) { 
Note: See TracChangeset for help on using the changeset viewer.