Model_apismt.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <?php
  2. class Model_Apismt extends Lin_Model {
  3. function __construct(){
  4. parent::__construct();
  5. }
  6. public function get_ex($code) //查看支持快递
  7. {
  8. $ch = curl_init();
  9. $url = 'http://39.100.97.180/smt.php';
  10. curl_setopt($ch,CURLOPT_URL,$url);
  11. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  12. curl_setopt($ch,CURLOPT_HEADER,0);
  13. curl_setopt($ch,CURLOPT_POST, 1);
  14. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  15. //设置post数据
  16. $post = array();
  17. $post['code'] = $code;
  18. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  19. $res = curl_exec($ch);
  20. curl_close($ch);
  21. $res = json_decode($res,true);
  22. if(isset($res))
  23. {
  24. return $res;
  25. }
  26. }
  27. public function get_hq($page,$size,$starttime,$endtime,$state,$code) //获取
  28. {
  29. $ch = curl_init();
  30. //$url = 'http://39.100.97.180/start/order';
  31. $url = 'http://39.100.97.180/smt.php';
  32. curl_setopt($ch,CURLOPT_URL,$url);
  33. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  34. curl_setopt($ch,CURLOPT_HEADER,0);
  35. curl_setopt($ch,CURLOPT_POST, 1);
  36. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  37. //设置post数据
  38. $post = array();
  39. $post['order_list'] = 1;
  40. $post['starttime'] = $starttime;
  41. $post['endtime'] = $endtime;
  42. $post['page'] = $page;
  43. $post['size'] = $size;
  44. $post['state'] = $state;
  45. $post['code'] = $code;
  46. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  47. $res = curl_exec($ch);
  48. curl_close($ch);
  49. $res = json_decode($res,true);
  50. if(isset($res))
  51. {
  52. return $res;
  53. }
  54. }
  55. public function get_hqfull($page,$size,$starttime,$endtime,$state,$code) //获取
  56. {
  57. $ch = curl_init();
  58. //$url = 'http://39.100.97.180/start/orderfull';
  59. $url = 'http://39.100.97.180/smt.php';
  60. curl_setopt($ch,CURLOPT_URL,$url);
  61. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  62. curl_setopt($ch,CURLOPT_HEADER,0);
  63. curl_setopt($ch,CURLOPT_POST, 1);
  64. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  65. //设置post数据
  66. $post = array();
  67. $post['order_list_full'] = 1;
  68. $post['starttime'] = $starttime;
  69. $post['endtime'] = $endtime;
  70. $post['page'] = $page;
  71. $post['size'] = $size;
  72. $post['state'] = $state;
  73. $post['code'] = $code;
  74. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  75. $res = curl_exec($ch);
  76. curl_close($ch);
  77. $res = json_decode($res,true);
  78. $data = array();$fund_status = '';
  79. if(isset($res['result']['target_list']['aeop_order_item_dto']))
  80. {
  81. foreach ($res['result']['target_list']['aeop_order_item_dto'] as $v)
  82. {
  83. if(!isset($v['fund_status']))
  84. {
  85. $fund_status = 'NOT_PAY';
  86. }
  87. if($fund_status = 'NOT_PAY' && isset($v['gmt_pay_time']))
  88. {
  89. $fund_status = 'PAY_SUCCESS';
  90. }
  91. if(isset($v['order_id']) && isset($v['order_status']) && isset($v['buyer_login_id']))
  92. {
  93. $data[] = array('orderinfo'=>$v['order_id'],'state'=>$v['order_status'],'userid'=>$v['buyer_login_id'],'fundstate'=>$fund_status);
  94. }
  95. }
  96. return $data;
  97. }
  98. }
  99. public function get_order($orderid,$code) //详情
  100. {
  101. $ch = curl_init();
  102. //$url = 'http://39.100.97.180/start/data';
  103. $url = 'http://39.100.97.180/smt.php';
  104. curl_setopt($ch,CURLOPT_URL,$url);
  105. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  106. curl_setopt($ch,CURLOPT_HEADER,0);
  107. curl_setopt($ch,CURLOPT_POST, 1);
  108. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  109. //设置post数据
  110. $post = array();
  111. $post['order_id'] = 1;
  112. $post['orderid'] = $orderid;
  113. $post['code'] = $code;
  114. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  115. $res = curl_exec($ch);
  116. curl_close($ch);
  117. $this->logic_ding->sendToDing("速卖通获取订单详情监视".$orderid."【".$res."】");
  118. $res = json_decode($res,true);
  119. if(isset($res))
  120. {
  121. return $res;
  122. }
  123. }
  124. public function get_out($whlabel,$all,$orderinfo,$ex,$code) //发货声明
  125. {
  126. $ch = curl_init();
  127. //$url = 'http://39.100.97.180/start/out';
  128. $url = 'http://39.100.97.180/smt.php';
  129. curl_setopt($ch,CURLOPT_URL,$url);
  130. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  131. curl_setopt($ch,CURLOPT_HEADER,0);
  132. curl_setopt($ch,CURLOPT_POST, 1);
  133. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  134. //设置post数据
  135. $post = array();
  136. $post['order_out'] = 1;
  137. $post['whlabel'] = $whlabel;
  138. $post['all'] = $all;
  139. $post['orderinfo'] = $orderinfo;
  140. $post['ex'] = $ex;
  141. $post['code'] = $code;
  142. $this->logic_ding->sendToDing("SMT运单同步".json_encode($post,JSON_UNESCAPED_UNICODE));
  143. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  144. $res = curl_exec($ch);
  145. curl_close($ch);
  146. $res = json_decode($res,true);
  147. if(isset($res))
  148. {
  149. return $res;
  150. }
  151. }
  152. public function get_obtain($orderinfo,$code) //查询声明
  153. {
  154. $ch = curl_init();
  155. //$url = 'http://39.100.97.180/start/obtain';
  156. $url = 'http://39.100.97.180/smt.php';
  157. curl_setopt($ch,CURLOPT_URL,$url);
  158. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  159. curl_setopt($ch,CURLOPT_HEADER,0);
  160. curl_setopt($ch,CURLOPT_POST, 1);
  161. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  162. //设置post数据
  163. $post = array();
  164. $post['statement'] = 1;
  165. $post['orderinfo'] = $orderinfo;
  166. $post['code'] = $code;
  167. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  168. $res = curl_exec($ch);
  169. curl_close($ch);
  170. $res = json_decode($res,true);
  171. if(isset($res))
  172. {
  173. return $res;
  174. }
  175. }
  176. public function get_editout($oldwhlabel,$whlabel,$all,$orderinfo,$oldex,$ex,$code) //更改声明
  177. {
  178. $ch = curl_init();
  179. //$url = 'http://39.100.97.180/start/editout';
  180. $url = 'http://39.100.97.180/smt.php';
  181. curl_setopt($ch,CURLOPT_URL,$url);
  182. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  183. curl_setopt($ch,CURLOPT_HEADER,0);
  184. curl_setopt($ch,CURLOPT_POST, 1);
  185. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  186. //设置post数据
  187. $post = array();
  188. $post['editstatement'] = 1;
  189. $post['oldwhlabel'] = $oldwhlabel;
  190. $post['whlabel'] = $whlabel;
  191. $post['all'] = $all;
  192. $post['orderinfo'] = $orderinfo;
  193. $post['oldex'] = $oldex;
  194. $post['ex'] = $ex;
  195. $post['code'] = $code;
  196. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  197. $res = curl_exec($ch);
  198. curl_close($ch);
  199. $res = json_decode($res,true);
  200. if(isset($res))
  201. {
  202. return $res;
  203. }
  204. }
  205. public function get_msg($shopid,$userid,$content,$code,$order) //发送站内信
  206. {
  207. $ch = curl_init();
  208. //$url = 'http://39.100.97.180/start/msg';
  209. $url = 'http://39.100.97.180/smt.php';
  210. curl_setopt($ch,CURLOPT_URL,$url);
  211. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  212. curl_setopt($ch,CURLOPT_HEADER,0);
  213. curl_setopt($ch,CURLOPT_POST, 1);
  214. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  215. //设置post数据
  216. $post = array();
  217. $post['shopid'] = $shopid;
  218. $post['userid'] = $userid;
  219. $post['message_type'] = 'order';
  220. $post['content'] = $content;
  221. $post['code'] = $code;
  222. $post['order'] = $order;
  223. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  224. $res = curl_exec($ch);
  225. curl_close($ch);
  226. $res = json_decode($res,true);
  227. if(isset($res))
  228. {
  229. return $res;
  230. }
  231. }
  232. public function get_commoditylist($page,$size,$code) //获取商品列表
  233. {
  234. $ch = curl_init();
  235. //$url = 'http://39.100.97.180/start/commoditylist';
  236. $url = 'http://39.100.97.180/smt.php';
  237. curl_setopt($ch,CURLOPT_URL,$url);
  238. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  239. curl_setopt($ch,CURLOPT_HEADER,0);
  240. curl_setopt($ch,CURLOPT_POST, 1);
  241. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  242. //设置post数据
  243. $post = array();
  244. $post['order_commodity_list'] = 1;
  245. $post['page'] = $page;
  246. $post['size'] = $size;//小于等于100
  247. $post['type'] = 'onSelling';//商品业务状态,目前提供5种,输入参数分别是:上架:onSelling ;下架:offline ;审核中:auditing ;审核不通过:editingRequired;客服删除:service_delete
  248. $post['code'] = $code;
  249. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  250. $res = curl_exec($ch);
  251. curl_close($ch);
  252. $res = json_decode($res,true);
  253. if(isset($res))
  254. {
  255. return $res;
  256. }
  257. }
  258. public function get_commodityread($data,$code) //商品详情
  259. {
  260. $ch = curl_init();
  261. //$url = 'http://39.100.97.180/start/commodityread';
  262. $url = 'http://39.100.97.180/smt.php';
  263. curl_setopt($ch,CURLOPT_URL,$url);
  264. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  265. curl_setopt($ch,CURLOPT_HEADER,0);
  266. curl_setopt($ch,CURLOPT_POST, 1);
  267. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  268. //设置post数据
  269. $post = array();
  270. $post['order_commodity_read'] = 1;
  271. $post['data'] = $data;
  272. $post['code'] = $code;
  273. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  274. $res = curl_exec($ch);
  275. curl_close($ch);
  276. $res = json_decode($res,true);
  277. $sku = array();
  278. if(isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']))
  279. {
  280. $gg = array();
  281. if(!isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku'][0]))
  282. {
  283. foreach ($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['aeop_s_k_u_property_list']['aeop_sku_property'] as $vg)
  284. {
  285. if(isset($vg['property_value_definition_name']))
  286. {
  287. $gg[$vg['property_value_id']] = $vg['property_value_definition_name'];
  288. }
  289. }
  290. $code = isset($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['sku_code'])?$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['sku_code']:'';
  291. $sku[$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['id']] = array('skuid'=>$res['aeop_ae_product_s_k_us']['aeop_ae_product_sku']['id'],'code'=>$code);
  292. }
  293. else
  294. {
  295. foreach ($res['aeop_ae_product_s_k_us']['aeop_ae_product_sku'] as $vv)
  296. {
  297. foreach ($vv['aeop_s_k_u_property_list']['aeop_sku_property'] as $vg)
  298. {
  299. if(isset($vg['property_value_definition_name']))
  300. {
  301. $gg[$vg['property_value_id']] = $vg['property_value_definition_name'];
  302. }
  303. }
  304. $code = isset($vv['sku_code'])?$vv['sku_code']:'';
  305. $sku[$vv['id']] = array('skuid'=>$vv['id'],'code'=>$code);
  306. }
  307. }
  308. $img = explode(';',$res['image_u_r_ls']);
  309. $title = '';
  310. if(isset($res['subject_list']['subject'][14]['value']))
  311. {
  312. $title = $res['subject_list']['subject'][14]['value'];
  313. }
  314. else if(isset($res['subject_list']['subject']['locale']))
  315. {
  316. if($res['subject_list']['subject']['locale'] == 'en_US')
  317. {
  318. $title = $res['subject_list']['subject']['value'];
  319. }
  320. }
  321. else
  322. {
  323. foreach ($res['subject_list']['subject'] as $rv)
  324. {
  325. if($rv['locale'] == 'en_US')
  326. {
  327. $title = $rv['value'];
  328. }
  329. }
  330. }
  331. @$mid = array('productid'=>$res['product_id'],'img'=>$img[0],'title'=>$title,'type'=>$res['product_status_type'],'cid'=>$res['category_id'],'sku'=>$sku,'gg'=>$gg);
  332. return $mid;
  333. }
  334. else
  335. {
  336. $myfile = fopen("./data/errors/txt/".$data.'-'.date('Ymd_His',time()).".txt", "w");
  337. $txt = json_encode($res);
  338. fwrite($myfile,$txt);
  339. fclose($myfile);
  340. return 1;exit;
  341. }
  342. }
  343. public function get_commoditysku($data,$code) //商品类目(sku)
  344. {
  345. $ch = curl_init();
  346. //$url = 'http://39.100.97.180/start/commoditysku';
  347. $url = 'http://39.100.97.180/smt.php';
  348. curl_setopt($ch,CURLOPT_URL,$url);
  349. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  350. curl_setopt($ch,CURLOPT_HEADER,0);
  351. curl_setopt($ch,CURLOPT_POST, 1);
  352. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  353. //设置post数据
  354. $post = array();
  355. $post['order_commodity_sku'] = 1;
  356. $post['sku'] = $data;
  357. $post['code'] = $code;
  358. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  359. $res = curl_exec($ch);
  360. curl_close($ch);
  361. $res = json_decode($res,true);
  362. if(isset($res))
  363. {
  364. return $res;
  365. }
  366. }
  367. public function get_logistics9($data,$orderinfo,$express,$al) //速卖通物流接口
  368. {
  369. $ch = curl_init();
  370. //$url = 'http://39.100.97.180/start/logistics';
  371. $url = 'http://39.100.97.180/smt.php';
  372. curl_setopt($ch,CURLOPT_URL,$url);
  373. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  374. curl_setopt($ch,CURLOPT_HEADER,0);
  375. curl_setopt($ch,CURLOPT_POST, 1);
  376. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  377. //设置post数据
  378. $post = array();
  379. $post['logistics'] = 1;
  380. $post['waybill'] = $waybill;
  381. $post['ESCROW'] = 'ESCROW';
  382. $post['orderinfo'] = $orderinfo;
  383. $post['express'] = $express;
  384. $post['al'] = $al;
  385. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  386. $res = curl_exec($ch);
  387. curl_close($ch);
  388. $res = json_decode($res,true);
  389. if(isset($res))
  390. {
  391. return $res;
  392. }
  393. }
  394. public function get_logistics($v) //阿里云云市场
  395. {
  396. $host = "https://ali-deliver.showapi.com";
  397. $path = "/showapi_expInfo";
  398. $method = "GET";
  399. $appcode = "008b9815e9fa49c49ba3a95f83f662f6";
  400. $headers = array();
  401. array_push($headers, "Authorization:APPCODE " . $appcode);
  402. $waybill = ($v['express'] == 'usps')?str_replace(array('420',$v['zipcode']),array('',''),$v['waybill']):$v['waybill'];
  403. $querys = "com=".$v['cxcode']."&nu=".$waybill;
  404. $bodys = "";
  405. $url = $host . $path . "?" . $querys;
  406. $v['exstate'] = (isset($v['exstate']))?$v['exstate']:'';//非订单查询无此属性
  407. $curl = curl_init();
  408. curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
  409. curl_setopt($curl, CURLOPT_URL, $url);
  410. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  411. curl_setopt($curl, CURLOPT_FAILONERROR, false);
  412. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  413. //curl_setopt($curl, CURLOPT_HEADER, true);
  414. if (1 == strpos("$".$host, "https://"))
  415. {
  416. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  417. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  418. }
  419. $read = json_decode(curl_exec($curl),true);
  420. if(!isset($read['showapi_res_body']['status']))
  421. {
  422. $content = (isset($read['showapi_res_body']['msg']))?date('Y-m-d H',time()).'-'.$read['showapi_res_body']['msg']:date('Y-m-d H',time()).'-'.'查询失败';
  423. $list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
  424. }
  425. else if($read['showapi_res_body']['status'] > 1 && $read['showapi_res_body']['status'] != $v['exstate'])
  426. {
  427. $exstate = $read['showapi_res_body']['status'];
  428. $content = $read['showapi_res_body']['data'][0]['time'].' - '.$read['showapi_res_body']['data'][0]['context'];
  429. $xq = '';
  430. foreach($read['showapi_res_body']['data'] as $v)
  431. {
  432. $xq .= $v['time'].' '.$v['context'].'<br />';
  433. }
  434. if($exstate == 2)
  435. {
  436. $exstate = 3;
  437. }
  438. else if($exstate == 3)
  439. {
  440. $exstate = 5;
  441. }
  442. else if($exstate == 4)
  443. {
  444. $exstate = 6;
  445. }
  446. else if($exstate == 9 || $exstate == 5)
  447. {
  448. $exstate = 1;
  449. }
  450. $list = array('exstate'=>$exstate,'content'=>$content,'f'=>1,'data'=>$xq);//正常可发送站内信
  451. }
  452. else
  453. {
  454. $content = (isset($read['showapi_res_body']['msg']))?date('Y-m-d H',time()).'-'.$read['showapi_res_body']['msg']:date('Y-m-d H',time()).'-'.'查询失败';
  455. $list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
  456. }
  457. return $list;
  458. //status : -1 待查询 0 查询异常 1 暂无记录 2 在途中 3 派送中 4 已签收 5 用户拒签 6 疑难件 7 无效单 8 超时单 9 签收失败 10 退回
  459. }
  460. public function get_logistics1($data) //快递100
  461. {
  462. $key = 'jUQDydMC8647';//客户授权key
  463. $customer = '2C11630697BD4A3F260479649ADD9236'; //查询公司编号
  464. $param = array (
  465. 'com' => $data['express'], //快递公司编码
  466. 'num' => $data['waybill'], //快递单号
  467. 'phone' => '', //手机号
  468. 'from' => '', //出发地城市
  469. 'to' => '', //目的地城市
  470. 'resultv2' => '1' //开启行政区域解析
  471. );
  472. //请求参数
  473. $post_data = array();
  474. $post_data["customer"] = $customer;
  475. $post_data["param"] = json_encode($param);
  476. $sign = md5($post_data["param"].$key.$post_data["customer"]);
  477. $post_data["sign"] = strtoupper($sign);
  478. $url = 'http://poll.kuaidi100.com/poll/query.do'; //实时查询请求地址
  479. $params = "";
  480. foreach ($post_data as $k=>$v) {
  481. $params .= "$k=".urlencode($v)."&"; //默认UTF-8编码格式
  482. }
  483. $post_data = substr($params, 0, -1);
  484. $ch = curl_init();
  485. curl_setopt($ch, CURLOPT_POST, 1);
  486. curl_setopt($ch, CURLOPT_HEADER, 0);
  487. curl_setopt($ch, CURLOPT_URL, $url);
  488. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  489. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  490. $result = curl_exec($ch);
  491. $data = str_replace("\"", '"', $result );
  492. return json_decode($data);
  493. }
  494. //快递鸟查询快递信息开始
  495. public function get_logistics3($data){
  496. $requestData= "{'OrderCode':'','ShipperCode':'".$data['express']."','LogisticCode':'".$data['waybill']."'}";
  497. $datas = array(
  498. 'EBusinessID' => '1397054',
  499. 'RequestType' => '8001',
  500. 'RequestData' => urlencode($requestData) ,
  501. 'DataType' => '2',
  502. );
  503. $datas['DataSign']=$this->_encrypt($requestData,'34aedf94-322e-438e-b6ba-79eea59710bd');
  504. $result=$this->_sendPost('http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx',$datas);
  505. return $result;
  506. }
  507. public function _sendPost($url,$datas) {
  508. $temps = array();
  509. foreach ($datas as $key => $value) {
  510. $temps[] = sprintf('%s=%s', $key, $value);
  511. }
  512. $post_data = implode('&', $temps);
  513. $url_info = parse_url($url);
  514. if(empty($url_info['port']))
  515. {
  516. $url_info['port']=80;
  517. }
  518. $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
  519. $httpheader.= "Host:" . $url_info['host'] . "\r\n";
  520. $httpheader.= "Content-Type:application/x-www-form-urlencoded\r\n";
  521. $httpheader.= "Content-Length:" . strlen($post_data) . "\r\n";
  522. $httpheader.= "Connection:close\r\n\r\n";
  523. $httpheader.= $post_data;
  524. $fd = fsockopen($url_info['host'], $url_info['port']);
  525. fwrite($fd, $httpheader);
  526. $gets = "";
  527. $headerFlag = true;
  528. while (!feof($fd)) {
  529. if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) {
  530. break;
  531. }
  532. }
  533. while (!feof($fd)) {
  534. $gets.= fread($fd, 128);
  535. }
  536. fclose($fd);
  537. return $gets;
  538. }
  539. public function _encrypt($data,$appkey) {
  540. return urlencode(base64_encode(md5($data.$appkey)));
  541. }
  542. //快递鸟查询快递信息结束
  543. } //end class