Uber Api GET /我使用Curl不起作用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Uber Api GET /我使用Curl不起作用相关的知识,希望对你有一定的参考价值。

我正在尝试实施优步Api GET /我

Ref :- https://developer.uber.com/docs/riders/references/api/v1.2/me-get

They specified that :- Replace <TOKEN> in the example below with a user access token    

curl -H 'Authorization: Bearer <TOKEN>' 
         -H 'Accept-Language: en_US' 
         -H 'Content-Type: application/json' 
         'https://api.uber.com/v1.2/me'

I have write the above code in curl, but I am always getting "Error":"No authentication provided.","code":"unauthorized"

My Curl code is

<?php

    // Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.uber.com/v1.2/me");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");


    $headers = array();
    $headers[] = "Authorization: Bearer <token>";       #<token> has been replaced by my token
    $headers[] = "Accept-Language: en_US";      
    $headers[] = "Content-Type: application/json";
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    echo "<pre>";
    print_r($headers);

    $result = curl_exec($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    echo "<li>".$httpcode;
    echo "<pre>";print_r($result);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }
    curl_close ($ch);

I am always getting "Error":"No authentication provided.","code":"unauthorized"

Still this is not working. Is Uber Api stops working today ?
答案

基于研究,最终我能够得到解决方案.Uber返回

get
https://sandbox-api.uber.com/v1.2/me

Array
(
    [0] => Authorization: Token <My token>
    [1] => Accept-Language: en_US
    [2] => Content-Type: application/json
)
{"error":true,"message":"We have experienced a problem.","code":500,"content":null}

所以优步有问题。浪费了很多时间

以上是关于Uber Api GET /我使用Curl不起作用的主要内容,如果未能解决你的问题,请参考以下文章

get-pip.py 的 curl 不起作用:语法错误

php中的cURL不起作用

cURL 有时不起作用并给出空结果

示例 Spotify api 音频分析 CURL 命令有效,但是当我输入新歌曲 ID 时它不起作用 - 正确的命令是啥?

如何在不使用 curl 和 guzzle 的情况下从控制器 Laravel 调用 API,因为它不起作用 [关闭]

TLS 1.2 在 cURL 中不起作用