2016-04-04 74 views

回答

0
+0

在API文檔有這個選項,但是這不行, ' YOUR_SERVER_TOKEN在 捲曲-H '授權:令牌YOUR_SERVER_TOKEN' \ 的「https://api.uber。 com/v1/1' curl_setopt($ ch,CURLOPT_HTTPHEADER,array('Authorization:Token'。$ this-> server_token)); https://api.uber.com/v1.1/history return NULL# –

+0

[GET /v1.1/history](https://developer.uber.com/docs/v11-history)API端點需要帶有history_lite範圍的* OAuth 2.0不記名令牌*如果您的訪問令牌未使用該範圍被授予,您將收到401 Unauthorized錯誤。還要記住,**不記名記號與服務器記號不同**對於歷史記錄終端,您需要從成功用戶[認證和授權](https://developer.uber.com/docs) /認證#OAuth的20)。所以你必須做curl_setopt($ ch,CURLOPT_HTTPHEADER,array('Authorization:Bearer'。$ this-> access_token)); – bitek

+0

好的,我必須從授權通過POST方法來發送碼 $結果= postKeys( 「https://login.uber.com/oauth/v2/token」, \t陣列( \t \t 'client_secret'=> $設置[ '全球'] [ 'client_secret'], \t \t '的client_id'=> $設定[ '全球'] [ 'CLIENT_ID'], \t \t 'grant_type'=> 'authorization_code', \t \t '代碼' => substr($ _ GET [「code」],0,-2), \t \t),array('Content-type:application/x-www-form-urlencoded') ); 如果我這樣做,我返回invalid_grant http://devs.monomax.lclients.ru/token.php?code=7eJeL3kVWpBMFqMZRLD6AY4CItB2AC#_ –

0
  • 1)надоработатьснапримерhttp://localhost/loacation.php()

  • 2)ненадовырезатьлишниесимволыизпеременной代碼

    require_once 'uber.php'; $ settings = require_once'settings.php';如果(!isset($ _GET [「code」])){setcookie(「AccessToken」,「」,time() - 3600); ('Location:https://login.uber.com/oauth/v2/authorize?response_type=code&client_id='。$ settings ['global'] ['client_id']''& redirect_uri = localhost/location.php & client_secret ='。$ settings ['global'] ['client_secret']); die(); }

    $result = postKeys("https://login.uber.com/oauth/v2/token", 
        array(
         'client_secret'=>$settings['global']['client_secret'], 
         'client_id'=>$settings['global']['client_id'], 
         'grant_type'=> 'authorization_code', 
         'redirect_uri'=> 'http://localhost/location.php', 
         'code'=> $_GET["code"], 
         ), array('Content-type: application/x-www-form-urlencoded') 
    ); 
    // после получения ответа, проверяем на код 200, и если все хорошо, то у нас есть токен 
    if ($result["code"]==200) { 
        $result["response"]=json_decode($result["response"],true); 
        $token=$result["response"]["access_token"]; 
        $new = new Token($settings); 
        $new->setToken($token); 
    }else 
        echo "не правильный код: ".$result["code"].' '.$result['response'];