Model_apismt.php 18 KB

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