dongzhenqi2015 2019-04-11 15:01
浏览 31

使用PHP从REST API获取数据时出错

I'm trying to get data using CURL but I'm getting error "function is not implemented through authorised server".

When I contact with API support it says function is correct. Can anyone help me?

Note: XYZ is a shipstation company API for Shipping and i am trying to get orders status from there.

  $header = array();
  //$header[] = 'POST //xyz[dot]com/AuthServer/api/Token HTTP/1.1';
  $header[] = 'Host: xyz[dot]com';
  $header[] = 'Connection: keep-alive';
  $header[] = 'Content-Type: application/hal+json; charset=utf-8';
  $header[] = 'Accept: application/hal+json';
  $header[] = 'Authorization: Bearer '.$get_token['msg']->access_token;
  $header[] = 'Accept-Encoding: gzip,deflate,sdch';
  $header[] = 'Accept-Language: en-US,en;q=0.8';
  $header[] = 'Content-length: '.strlen($order_data_str);

  $ch = curl_init('http://xyz[dot]com/orders');
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $order_data_str);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

  $temp_status['status'] = 0;
  $temp_status['xyz_order_id'] = '';

  try{        
    $result1 = curl_exec($ch);
    $result = json_decode($result1); 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题