无法为访问令牌交换Uber API授权代码以获取当前行程详细信息

时间:2016-10-24 14:19:03

标签: php oauth-2.0 uber-api

一旦优步用户对我的应用进行身份验证和授权,我就会收到授权码,但我无法交换access_token的授权码。

我正在尝试使用以下方式获取当前行程信息: 的 https://developer.uber.com/docs/trip-experiences/references/api/v1-requests-current-get

// uber.php

echo $_GET['code']."<br>";
$token = curl_init();

$param = array(
    'client_secret' => 'xxxxxxxxxxxxxx',
    'client_id' => '_xxxxxxxxxxxxxxxxxxxxxx',
    'grant_type' => 'authorization_code',
    'redirect_uri' => 'http://localhost/uber/uber.php', // (the same as in app settings)
    'code' => "{$_GET['code']}"
    );

$postData = '';
foreach($param as $k => $v)
    {
       $postData .= $k . '='.urlencode($v).'&';
    }
$postData = rtrim($postData, '&');
curl_setopt($token, CURLOPT_URL, 'https://login.uber.com/oauth/v2/token');
curl_setopt($token, CURLOPT_HEADER, true);
curl_setopt($token, CURLOPT_RETURNTRANSFER, true);
curl_setopt($token, CURLOPT_POST, true);
curl_setopt($token, CURLOPT_POSTFIELDS, $postData);
$returned_token = curl_exec($token);
curl_close($token);

echo "<hr>";
echo $returned_token;
echo "<hr>";

我得到一个空白的输出。

1 个答案:

答案 0 :(得分:1)

加上这个:

function zoomBegin() {
  console.log("Zoom begin");
  svg.style("cursor", "move");
}

function zoomFinish() {
  console.log("Zoom finish");
  svg.style("cursor", "auto");
}

问题解决了......: - )