Model_apismt.php 18 KB

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