首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Uber Api使用Curl获取/me不起作用

Uber Api使用Curl获取/me不起作用
EN

Stack Overflow用户
提问于 2018-03-01 13:38:05
回答 1查看 276关注 0票数 1

我正在尝试实现Uber Api GET /me

代码语言:javascript
运行
复制
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 ?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-01 17:10:16

基于研究,我最终得到了solution.Uber的返回值

代码语言:javascript
运行
复制
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}

因此,优步遇到了问题。浪费了很多时间

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49043244

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档