PHP-demo code sharing of ExPRESS Logistics interface

Source: Internet
Author: User
This article describes the sample code sharing of the PHP-ExPRESS Logistics interface demo, which has some reference value. let's take a look at it. PHP-demo code sharing of ExPRESS Logistics interface

 EBusinessID, 'requesttype' => '000000', 'requestdata' => urlencode ($ RequestData), 'ype Ype '=> '2 ',); $ datas ['datasign '] = encrypt ($ requestData, AppKey); $ result = sendPost (ReqURL, $ datas ); // process the returned information according to the company's business ...... return $ result;}/*** import the shipping template in Json format */function importCostTemplateByJson () {$ requestData = "{'memberid': '2016', 'detail ': [{'shippercode': 'yd ', 'sendprovince': 'Guangdong ', 'sendcity': 'Guangzhou', 'sendexparea ': 'Tianhe', 'receiveprovince ': 'hunan', 'regionecity ': 'Changsha', 'receiveexparea ': 'longgang', 'firstight ': '1 ', 'firstance': '8', 'additionalweight ': '1', 'additionaloutput': '10', 'weightformula': ''}, {'shippercode ': 'yd ', 'sendprovince': 'Guangdong ', 'sendcity': 'Guangzhou', 'sendexparea ': 'tianhe', 'receiveprovince ': 'hunan', 'regionecity ': 'Changsha ', 'receiveexparea': 'yuhua ', 'firstight': '1', 'firstup': '8', 'additionalupt': '1', 'additionalupt ': '10', 'weightformu La ':' {w-0}-0.4} * {1000-w}-0.4} + 1} * 4.700 + {w-1000}-0.6} * [(w-1000) /1000] * 4.700) ', 'shippingtype': '1', 'intervallist': [{'startweight': 1.0, 'endweight': 2.0, 'weight ': 3.0}]} "; $ datas = array ('ebusinessid '=> EBusinessID, 'requesttype' => '000000', 'requestdata' => urlencode ($ RequestData ), 'ype Ype '=> '2',); $ datas ['datasign'] = encrypt ($ requestData, AppKey); $ result = sendPost (ReqURL, $ datas ); // according Information returned by the company's business processing ...... return $ result ;} /*** post submit data ** @ param string $ url request Url * @ param array $ data submitted by datas * @ return url response returned html */function sendPost ($ url, $ datas) {$ temps = array (); foreach ($ datas as $ key => $ value) {$ temps [] = sprintf ('% s = % s ', $ key, $ value) ;}$ post_data = implode ('&', $ temps); $ url_info = parse_url ($ url ); if (empty ($ url_info ['port']) {$ url_info ['port'] = 80;} $ httpheader = "PO ST ". $ url_info ['path']. "HTTP/1.0 \ r \ n"; $ httpheader. = "Host :". $ url_info ['host']. "\ r \ n"; $ httpheader. = "Content-Type: application/x-www-form-urlencoded \ r \ n"; $ httpheader. = "Content-Length :". strlen ($ post_data ). "\ r \ n"; $ httpheader. = "Connection: close \ r \ n"; $ httpheader. = $ post_data; $ fd = fsockopen ($ url_info ['host'], $ url_info ['port']); fwrite ($ fd, $ httpheader ); $ gets = ""; $ headerFlag = True; while (! Feof ($ fd) {if ($ header = @ fgets ($ fd )) & ($ header = "\ r \ n" | $ header = "\ n") {break ;}} while (! Feof ($ fd) {$ gets. = fread ($ fd, 128);} fclose ($ fd); return $ gets ;} /*** e-commerce Sign Generation * @ param data content * @ param appkey Appkey * @ return DataSign signature */function encrypt ($ data, $ appkey) {return urlencode (base64_encode (md5 ($ data. $ appkey) ;}?>

The above is the details shared by the PHP-ExPRESS Logistics Interface demo sample code. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.