邮递员通过php代码发送的请求未正确处理

时间:2020-03-30 20:17:58

标签: php api postman

我尝试用php构建程序,该程序将请求发送到邮递员api,并以json格式获取结果 但是,当我直接尝试邮递员时,它可以工作,但不适用于php代码。 下面的代码是由邮递员api生成的

<?php

 $curl = curl_init();
 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt_array($curl, array(
 CURLOPT_URL => "https://rs-gw-temp-1813297076.eu-central-1.elb.amazonaws.com/route/json? 
 waypoints=11.61207,52.110531;11.62727,52.10668&route- 
 annotations=traffic_costs_summary,static_costs_summary&real-time-traffic=true&route- 
 formats=polyline_smooth,links,deviations%0A",
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => "",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 0,
 CURLOPT_FOLLOWLOCATION => true,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => "GET",
  ));

 $response = curl_exec($curl);
 if(curl_errno($curl))
 {
 $erro_msg = curl_error($curl);
 echo $erro_msg;
 }

 var_dump(json_decode($response));

 curl_close($curl);

输出:

object(stdClass)#1 (3) {
  ["error_status"]=>
  int(2)
  ["error_title"]=>
  string(23) "Invalid parameter value"
  ["error_desc"]=>
  string(20) "Unknown route format"
}

enter image description here

0 个答案:

没有答案