【发布时间】:2016-10-12 07:42:51
【问题描述】:
正在尝试测试 Uber Rush API(来自 localhost 和 linux 服务器)。
调用令牌有效 - 我得到令牌 尝试实现 sanbox 示例:
curl -X "PUT /v1/sandbox/deliveries/{delivery_id}" \
-H "Authorization: Bearer <OAUTH TOKEN>" \
-d "{\"status\":\"en_route_to_pickup\"}"
带有网址https://sandbox-api.uber.com/
我用 file_get_contents 尝试了同样的请求(在 PHP 中)
所以,我总是收到错误“405 Method Not Allowed”
{"message":"Method not supported for this endpoint.","code":"method_not_allowed"}
我需要做什么才能从这个沙盒示例https://developer.uber.com/docs/rush/sandbox 访问方法?
正确的语法
curl -X "PUT" -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" -d "{\"status\":\"en_route_to_pickup\"}" https://sandbox-api.uber.com/v1/sandbox/deliveries/DELIVERY_ID
【问题讨论】:
-
您对 file_get_contents 的确切调用是什么?
-
$url = 'https://sandbox-api.uber.com/v1/sandbox/deliveries/ID_HERE'; $headers = array( 'Authorization: Bearer '.TOKEN_HERE); $options = array( 'https' => array( 'header'=> $headers , ), ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context);
标签: uber-api