[5341] | 1 | <?php |
---|
[5399] | 2 | require_once (dirname(__FILE__).'/api/controller.php'); |
---|
[6528] | 3 | use prototype\api\Config as Config; |
---|
[5341] | 4 | |
---|
[5399] | 5 | $me = Controller::read(array('concept' => 'user', 'service' => 'OpenLDAP' , 'id' => Config::me('uidNumber'))); |
---|
[5341] | 6 | |
---|
[6572] | 7 | // |
---|
| 8 | //if(isset($_POST['refreshToken'])){ |
---|
| 9 | // |
---|
| 10 | // $ch = curl_init(); |
---|
| 11 | // |
---|
| 12 | // $restConf = parse_ini_file( __DIR__ . '/config/REST.ini', true ); |
---|
| 13 | // |
---|
| 14 | // $param = 'grant_type=refresh_token'; |
---|
| 15 | // $param .= '&client_id=' . $restConf['oauth']['client_id']; |
---|
| 16 | // $param .= '&client_secret=' . $restConf['oauth']['client_secret']; |
---|
| 17 | // $param .= '&refresh_token=' . $_SESSION['oauth']['refresh_token']; |
---|
| 18 | // |
---|
| 19 | // // set URL and other appropriate options |
---|
| 20 | // curl_setopt($ch, CURLOPT_URL, $restConf['oauth']['url_token']); |
---|
| 21 | // curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*')); |
---|
| 22 | // curl_setopt($ch, CURLOPT_POST, TRUE); |
---|
| 23 | // curl_setopt($ch, CURLOPT_POSTFIELDS, $param); |
---|
| 24 | // curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //configura para nao imprimir a saida na tela |
---|
| 25 | // 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. |
---|
| 26 | // |
---|
| 27 | // // grab URL and pass it to the browser |
---|
| 28 | // $res = curl_exec($ch); |
---|
| 29 | // |
---|
| 30 | // // close cURL resource, and free up system resources |
---|
| 31 | // curl_close($ch); |
---|
| 32 | // $a = json_decode($res); |
---|
| 33 | // |
---|
| 34 | // if ( isset($a->access_token) ) { |
---|
| 35 | // $_SESSION['oauth']['access_token'] = $a->access_token; |
---|
| 36 | // $_SESSION['oauth']['expires_in'] = $a->expires_in; |
---|
| 37 | // $_SESSION['oauth']['token_type'] = $a->token_type; |
---|
| 38 | // $_SESSION['oauth']['scope'] = $a->scope; |
---|
| 39 | // $_SESSION['oauth']['refresh_token'] = $a->refresh_token; |
---|
| 40 | // $_SESSION['oauth']['client_secret'] = $restConf['oauth']['client_secret']; |
---|
| 41 | // } else { |
---|
| 42 | // echo json_encode(null); |
---|
| 43 | // return; |
---|
| 44 | // } |
---|
| 45 | //} |
---|
[6528] | 46 | |
---|
| 47 | |
---|
[6572] | 48 | $me['token'] = 'asdf1as5d1f56a1sdf1qw5e1q2we5qfq8ew';//$_SESSION['oauth']['access_token']; |
---|
[5399] | 49 | echo json_encode( $me ); |
---|
| 50 | |
---|
| 51 | // if( !$me ) |
---|
| 52 | // return; |
---|
| 53 | // |
---|
| 54 | // $links = Controller::links(); |
---|
| 55 | // |
---|
| 56 | // $return = array(); |
---|
| 57 | // |
---|
| 58 | // foreach( $links as $concept => $link ) |
---|
| 59 | // { |
---|
| 60 | // $concepts = array(); |
---|
| 61 | // |
---|
| 62 | // foreach( $link as $linkName => $linkTarget ) |
---|
| 63 | // if( Controller::isConcept( $linkName ) ) |
---|
| 64 | // $concepts[ $linkName ] = true; |
---|
| 65 | // |
---|
| 66 | // $return[ $concept ] = array( 'concepts' => $concepts, 'links' => $link ); |
---|
| 67 | // } |
---|
| 68 | // |
---|
| 69 | // echo json_encode( array( 'me' => $me, 'links' => $return ) ); |
---|