Kd100.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace logistics;
  3. use think\Env;
  4. class Kd100 extends QueryInterface{
  5. protected $key;
  6. protected $customer;
  7. public function __construct()
  8. {
  9. $this->key=Env::get('logistics.kd100_key','fVczXhfg8960');
  10. $this->customer=Env::get('logistics.kd100_customer','B20CCD1C0BAFDD7E69CC986A1A0C57E0');
  11. }
  12. public function query()
  13. {
  14. //====================================
  15. // 实时查询示例代码
  16. // 授权信息可通过链接查看:https://api.kuaidi100.com/manager/v2/myinfo/enterprise
  17. //====================================
  18. //参数设置
  19. $key = $this->key; // 客户授权key
  20. $customer = $this->customer; // 查询公司编号
  21. $param = array (
  22. 'com' => $this->getLogistics('code_kd100'), // 快递公司编码
  23. 'num' => $this->getNo(), // 快递单号
  24. 'phone' => $this->getPhone(), // 手机号
  25. 'from' => '', // 出发地城市
  26. 'to' => '', // 目的地城市
  27. 'resultv2' => '1', // 开启行政区域解析
  28. 'show' => '0', // 返回格式:0:json格式(默认),1:xml,2:html,3:text
  29. 'order' => 'desc' // 返回结果排序:desc降序(默认),asc 升序
  30. );
  31. //请求参数
  32. $post_data = array();
  33. $post_data['customer'] = $customer;
  34. $post_data['param'] = json_encode($param, JSON_UNESCAPED_UNICODE);
  35. $sign = md5($post_data['param'].$key.$post_data['customer']);
  36. $post_data['sign'] = strtoupper($sign);
  37. $url = 'https://poll.kuaidi100.com/poll/query.do'; // 实时查询请求地址
  38. }
  39. }