123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- class Model_17track extends Lin_Model {
- function __construct(){
- parent::__construct();
- }
- public function get_logistics($v) //17track.net
- {
- $url = 'https://api.17track.net/track/v2.2/register';
- $header[] = "17token:0811AC1711EAABB7D764D04B824F8C2D";
- $header[] = "Content-Type:application/json";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $v);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,2);
- $res = curl_exec($ch);
- curl_close($ch);
- $res = json_decode($res,true);
- if(isset($res['data']['accepted']['0']['origin']))//成功
- {
- $list = array('exstate'=>0,'content'=>'','f'=>1,'data'=>'','webhookregister'=>1);
- }
- else if(isset($res['data']['rejected']['0']['error']['code']) && $res['data']['rejected']['0']['error']['code'] == '-18019901')//重复注册
- {
- $list = array('exstate'=>0,'content'=>'','f'=>1,'data'=>'','webhookregister'=>1);
- }
- else
- {
- $list = array('content'=>$res['data']['rejected']['0']['error']['message'],'f'=>0);
- }
- return $list;
- }
- /**
- * 根据快递单号获取物流信息
- * @param $params 快递单号数组
- */
- public function get_detail($params){
- $url = 'https://api.17track.net/track/v2.4/gettrackinfo';
- $header[] = "17token:0811AC1711EAABB7D764D04B824F8C2D";
- $header[] = "Content-Type:application/json";
-
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,2);
- $res = curl_exec($ch);
- curl_close($ch);
- $res = json_decode($res,true);
- return $res;
- }
- } //end class
|