123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826 |
- <?php
- //申请DHL用
- class Model_Dhlhz extends Lin_Model {
- function __construct(){
- parent::__construct();
- }
- public function get_data($data)//20210323升级新版API
- {
- if($data['pay'] == 1)
- {
- $data['pay'] == 'PayPal';
- }
- else if($data['pay'] == 2)
- {
- $data['pay'] == 'Western Union';
- }
- else if($data['pay'] == 3)
- {
- $data['pay'] == '微信';
- }
- else if($data['pay'] == 4)
- {
- $data['pay'] == '支付宝';
- }
- else if($data['pay'] == 5)
- {
- $data['pay'] == '银行转账';
- }
- else if($data['pay'] == 6)
- {
- $data['pay'] == '现金收款';
- }
- else if($data['pay'] == 7)
- {
- $data['pay'] == 'PingPong金融';
- }
- $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','puerto rico'=>'PR');
- $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
- $data['province'] = trim($data['province'],' ');
- if(isset($ToState[strtolower($data['province'])]))
- {
- $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
- $data['province'] = $dataprovince;
- }
- $sid = '606946403';
- $username = 'longyitechnCN';
- $password = 'S#5uZ#4vZ$2b';
- $xmend = "\n";
- $json = "<?xml version='1.0' encoding='UTF-8'?>".$xmend;
- $json .= '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ship="http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/ShipmentMsgRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">'.$xmend;
- $json .= '<soapenv:Header>'.$xmend;
- $json .= '<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:mustUnderstand="1">'.$xmend;
- $json .= '<wsse:UsernameToken wsu:Id="">'.$xmend;
- $json .= '<wsse:Username>'.$username.'</wsse:Username>'.$xmend;
- $json .= "<wsse:Password Type='PasswordText'>".$password."</wsse:Password>".$xmend;
- $json .= "<wsse:Nonce EncodingType='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'> eUYebYfsjztETJ4Urt8AJw ==</wsse:Nonce>".$xmend;
- $json .= '<wsu:Created>'.date('c').'</wsu:Created>'.$xmend;
- $json .= '</wsse:UsernameToken>'.$xmend;
- $json .= '</wsse:Security>'.$xmend;
- $json .= '</soapenv:Header>'.$xmend;
- $json .= '<soapenv:Body>'.$xmend;
- $json .= '<ship:ShipmentRequest>'.$xmend;
- $json .= '<Request>'.$xmend;
- $json .= '<ServiceHeader>'.$xmend;
- $json .= '<MessageTime>'.date('c').'</MessageTime>'.$xmend;//发送请求的时间
- $json .= '<MessageReference>'.time().time().rand(10000000,99999999).'</MessageReference>'.$xmend;//报文唯一标识
- $json .= '<WebstorePlatform>LYERP</WebstorePlatform>'.$xmend;//客户网店平台名称
- $json .= '<WebstorePlatformVersion>LY_V1.0.0</WebstorePlatformVersion>'.$xmend;//客户网店平台版本号
- $json .= '<ShippingSystemPlatform>LYERP</ShippingSystemPlatform>'.$xmend;//客户发件系统名称
- $json .= '<ShippingSystemPlatformVersion>LY_V1.0.0</ShippingSystemPlatformVersion>'.$xmend;//客户发件系统版本号
- $json .= '<PlugIn>LYERP</PlugIn>'.$xmend;//客户系统插件名称
- $json .= '<PlugInVersion>LY_V1.0.0</PlugInVersion>'.$xmend;//插件版本号
- $json .= '</ServiceHeader>'.$xmend;
- $json .= '</Request>'.$xmend;
- /** 请求装运信息 **/
- $json .= '<RequestedShipment>'.$xmend;
- /** 运单输出 **/
- $json .= '<ShipmentInfo>'.$xmend;
- $json .= '<DropOffType>REGULAR_PICKUP</DropOffType>'.$xmend;//取件类型 REGULAR_PICKUP不预约取件,REQUEST_COURIER预约取件
- $json .= '<ServiceType>P</ServiceType>'.$xmend;//产品代码,普通包裹:P,正午特派包裹:Y
- $json .= '<LocalServiceType>P</LocalServiceType>'.$xmend;//与ServiceType一致,可不保留
- $json .= '<Billing>'.$xmend;
- $json .= '<ShipperAccountNumber>'.$sid.'</ShipperAccountNumber>'.$xmend;//账号
- $json .= '<ShippingPaymentType>S</ShippingPaymentType>'.$xmend;//支付方式S--发件人,R--收件人,T--第三方
- $json .= '<BillingAccountNumber>'.$sid.'</BillingAccountNumber>'.$xmend;//DHL付款账号,当ShippingPaymentType为R或T时,此项为必填项
- $json .= '</Billing>'.$xmend;
- $json .= '<SpecialServices>'.$xmend;
- $json .= '<Service>'.$xmend;
- $json .= '<ServiceType>WY</ServiceType>'.$xmend;//WY无纸化贸易,DTP服务代码DD,PLT服务代码WY
- $json .= '</Service>'.$xmend;
- if($data['bx'] > 0)
- {
- $json .= '<Service>'.$xmend;
- $json .= '<ServiceType>II</ServiceType>'.$xmend;//II购买保险
- $json .= '<ServiceValue>'.$data['bx'].'</ServiceValue>'.$xmend;//保险金额
- $json .= '<CurrencyCode>USD</CurrencyCode>'.$xmend;//保险货币
- $json .= '</Service>'.$xmend;
- }
- $json .= '</SpecialServices>'.$xmend;
- $json .= '<Currency>USD</Currency>'.$xmend;//运费币种
- $json .= '<UnitOfMeasurement>SI</UnitOfMeasurement>'.$xmend;//重量单位SI表示千克和厘米,SU表示英镑和英寸
- $json .= '<ShipmentReferences>'.$xmend;
- $json .= '<ShipmentReference>'.$xmend;
- $json .= '<ShipmentReference>'.$data['number'].'</ShipmentReference>'.$xmend;
- $json .= '</ShipmentReference>'.$xmend;
- $json .= '</ShipmentReferences>'.$xmend;
- $json .= '<LabelType>PDF</LabelType>'.$xmend;//面单输出格式
- $json .= '<LabelTemplate>ECOM26_84_001</LabelTemplate>'.$xmend;//面单规格ECOM26_84_A4_001:A4纸运单,ECOM26_84_001:标签运单
- $json .= '<ArchiveLabelTemplate>ARCH_8x4</ArchiveLabelTemplate>'.$xmend;//ARCH_8X4_A4_002:A4纸运单,ARCH_8X4:标签运单Request中未添加该元素时,将默认为标签运单
- $json .= '<CustomsInvoiceTemplate>COMMERCIAL_INVOICE_L_10</CustomsInvoiceTemplate>'.$xmend;//海关发票模板
- $json .= '<PaperlessTradeEnabled>true</PaperlessTradeEnabled>'.$xmend;//启用无纸贸易
- $json .= '<LabelOptions>'.$xmend;
- $json .= '<PrinterDPI>200</PrinterDPI>'.$xmend;
- $json .= '<RequestWaybillDocument>N</RequestWaybillDocument>'.$xmend;//是否打印运单WaybillDoc联
- $json .= '<HideAccountInWaybillDocument>N</HideAccountInWaybillDocument>'.$xmend;//是否隐藏付款账号,Y隐藏,N不隐藏
- $json .= '<NumberOfWaybillDocumentCopies>1</NumberOfWaybillDocumentCopies>'.$xmend;//打印数量
- $json .= '<RequestDHLCustomsInvoice>Y</RequestDHLCustomsInvoice>'.$xmend;//是否需要发票
- $json .= '<DHLCustomsInvoiceLanguageCode>eng</DHLCustomsInvoiceLanguageCode>'.$xmend;//海关发票语言代码
- $json .= '<DHLCustomsInvoiceType>COMMERCIAL_INVOICE</DHLCustomsInvoiceType>'.$xmend;//海关发票类型
- $json .= '<RequestDHLLogoOnLabel>N</RequestDHLLogoOnLabel>'.$xmend;//是否打印DHL LOGO
- $json .= '</LabelOptions>'.$xmend;
- $json .= '</ShipmentInfo>'.$xmend;
- $json .= '<ShipTimestamp>'.date('Y-m-d',time()+19*3600).'T'.date('H:i:s',time()+19*3600).'GMT+08:00</ShipTimestamp>'.$xmend;//发货时间(预约取货时间开始)
- $json .= '<PaymentInfo>DAP</PaymentInfo>'.$xmend;//付款信息 !*
- /** 包裹和文件 **/
- $json .= '<InternationalDetail>'.$xmend;
- $json .= '<Commodities>'.$xmend;
- $json .= '<Description>'.$data['sbpm'].'</Description>'.$xmend;//商品描述,写报关货物内容,品名
- $json .= '<CustomsValue>'.$data['zsbjz'].'</CustomsValue>'.$xmend;//申报价值
- $json .= '</Commodities>'.$xmend;
- $json .= '<Content>NON_DOCUMENTS</Content>'.$xmend;//NON_DOCUMENTS为包裹,DOCUMENTS为文件
- $json .= '<ExportDeclaration>'.$xmend;
- $json .= '<ExportReasonType>COMMERCIAL_PURPOSE_OR_SALE</ExportReasonType>'.$xmend;
- $json .= '<PlaceOfIncoterm> </PlaceOfIncoterm>'.$xmend;//说是打空格可以通过 港口
- //循环开始
- $json .= '<ExportLineItems>'.$xmend;
- //(1)
- $json .= '<ExportLineItem>'.$xmend;
- $json .= '<CommodityCode>'.$data['hgbm'].'</CommodityCode>'.$xmend;//海关编码
- $json .= '<ExportReasonType>PERMANENT</ExportReasonType>'.$xmend;//出口原因可选值如下: - ‘PERMANENT’- ‘TEMPORARY’- ‘RETURN’
- $json .= '<ItemNumber>1</ItemNumber>'.$xmend;//物品序号
- $json .= '<Quantity>'.$data['ts'].'</Quantity>'.$xmend;//数量
- $json .= '<QuantityUnitOfMeasurement>PCS</QuantityUnitOfMeasurement>'.$xmend;//数量单位,条
- $json .= '<ItemDescription>'.$data['sbpm'].'</ItemDescription>'.$xmend;//商品描述
- $json .= '<UnitPrice>'.$data['dtsbjz'].'</UnitPrice>'.$xmend;//单条申报价
- $json .= '<NetWeight>'.$data['zzl'].'</NetWeight>'.$xmend;//净重
- $json .= '<GrossWeight>'.$data['zzl'].'</GrossWeight>'.$xmend;//总重量
- $json .= '<ManufacturingCountryCode>CN</ManufacturingCountryCode>'.$xmend;//制造国家代码
- $json .= '</ExportLineItem>'.$xmend;
- //循环结束
- $json .= '</ExportLineItems>'.$xmend;
- $json .= '<InvoiceDate>'.date('Y-m-d',time()).'</InvoiceDate>'.$xmend;//发票日期
- $json .= '<InvoiceNumber>'.$data['paypal'].' '.$data['pay'].'</InvoiceNumber>'.$xmend;//发票号码
- $json .= '<Remarks>'.$xmend;
- $json .= '<Remark>'.$xmend;
- $json .= '<RemarkDescription>'.$data['number'].'</RemarkDescription>'.$xmend;//备注说明
- $json .= '</Remark>'.$xmend;
- $json .= '</Remarks>'.$xmend;
- $json .= '</ExportDeclaration>'.$xmend;
- $json .= '</InternationalDetail>'.$xmend;
- $json .= '<Ship>'.$xmend;
- $json .= '<Shipper>'.$xmend;
- $json .= '<Contact>'.$xmend;
- $json .= '<PersonName>He Chong Bo</PersonName>'.$xmend;//发货人 '.$data['warehouse']['company'].'
- $json .= '<CompanyName>Kun Peng Fazhipin</CompanyName>'.$xmend;//'.$data['warehouse']['company'].'
- $json .= '<PhoneNumber>15939964739</PhoneNumber>'.$xmend;
- //$json .= '<EmailAddress></EmailAddress>'.$xmend;//发件人电子邮件
- $json .= '<MobilePhoneNumber>256345673</MobilePhoneNumber>'.$xmend;//发件人固话
- $json .= '</Contact>'.$xmend;
- $json .= '<Address>'.$xmend;
- $json .= '<StreetLines>4703,building C,</StreetLines>'.$xmend;//'.$data['warehouse']['address'].'
- $json .= '<StreetLines2>bodi center,ningwei street</StreetLines2>'.$xmend;//'.$data['warehouse']['address2'].'
- //$json .= '<StreetLines3></StreetLines3>'.$xmend;
- $json .= '<City>Hang Zhou</City>'.$xmend;//'.$data['warehouse']['city'].'
- $json .= '<StateOrProvinceCode>Zhe Jiang</StateOrProvinceCode>'.$xmend;//'.$data['warehouse']['province'].'
- $json .= '<PostalCode>311200</PostalCode>'.$xmend;//'.$data['warehouse']['zipcode'].'
- $json .= '<CountryCode>'.$data['warehouse']['lb'].'</CountryCode>'.$xmend;//国家代码
- $json .= '</Address>'.$xmend;
- $json .= '</Shipper>'.$xmend;
- $json .= '<Recipient>'.$xmend;
- $json .= '<Contact>'.$xmend;
- $json .= '<PersonName>'.$data['name'].'</PersonName>'.$xmend;//收货人
- $json .= '<CompanyName>'.$data['client'].'</CompanyName>'.$xmend;
- $json .= '<PhoneNumber>'.$data['phone'].'</PhoneNumber>'.$xmend;
- //$json .= '<EmailAddress></EmailAddress>'.$xmend;//发件人电子邮件
- //$json .= '<MobilePhoneNumber></MobilePhoneNumber>'.$xmend;//发件人固话
- $json .= '</Contact>'.$xmend;
- $json .= '<Address>'.$xmend;
- if(strlen($data['address'].$data['address2']) > 44)
- {
- $adl = $data['address'].$data['address2'];
- $adl1 = substr($adl,0,44);//截取44字符前内容
- $adlnum = strripos($adl1," ");//查找最后一次出现空格位置
- $adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
- $adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
- $json .= '<StreetLines>'.$adl1.'</StreetLines>'.$xmend;//收货人地址1
- $json .= '<StreetLines2>'.$adl2.'</StreetLines2>'.$xmend;//收货人地址2
- }
- else
- {
- $json .= '<StreetLines>'.$data['address'].$data['address2'].'</StreetLines>'.$xmend;//收货人地址
- }
- //$json .= '<StreetLines3></StreetLines3>'.$xmend;
- $json .= '<City>'.$data['city'].'</City>'.$xmend;
- if($data['lb'] == 'US')
- {
- $json .= '<StateOrProvinceCode>'.$data['province'].'</StateOrProvinceCode>'.$xmend;
- }
- $json .= '<PostalCode>'.$data['zipcode'].'</PostalCode>'.$xmend;
- $json .= '<CountryCode>'.$data['lb'].'</CountryCode>'.$xmend;//国家代码
- $json .= '</Address>'.$xmend;
- $json .= '</Recipient>'.$xmend;
- $json .= '</Ship>'.$xmend;
-
- $json .= '<Packages>'.$xmend;
- //多箱这里循环
- $json .= '<RequestedPackages number="'.$data['zjs'].'">'.$xmend;
- $json .= '<Weight>'.$data['zzl'].'</Weight>'.$xmend;
- $json .= '<Dimensions>'.$xmend;
- $json .= '<Length>5</Length>'.$xmend;
- $json .= '<Width>15</Width>'.$xmend;
- $json .= '<Height>3</Height>'.$xmend;
- $json .= '</Dimensions>'.$xmend;
- $json .= '<CustomerReferences>'.$data['number'].'</CustomerReferences>'.$xmend;
- $json .= '</RequestedPackages>'.$xmend;
- $json .= '</Packages>'.$xmend;
- //循环结束
- $json .= '</RequestedShipment>'.$xmend;
- $json .= '</ship:ShipmentRequest>'.$xmend;
- $json .= '</soapenv:Body>'.$xmend;
- $json .= '</soapenv:Envelope>'.$xmend;
-
-
- $ch = curl_init();
- //curl_setopt($ch, CURLOPT_URL,'https://wsbexpress.dhl.com:443/sndpt/expressRateBook');
- curl_setopt($ch, CURLOPT_URL,'https://wsbexpress.dhl.com:443/gbl/expressRateBook');
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:text/xml; charset=utf-8"));
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- $data = curl_exec($ch);
- curl_close($ch);
- $xml = simplexml_load_string($data);
- $xml->registerXPathNamespace('shipresp', 'http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/ShipmentMsgResponse');
- $data = array();
- foreach ($xml->xpath('//ShipmentIdentificationNumber') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- $data['waybill'] = $convrt_arr[0];
- break;
- }
- foreach ($xml->xpath('//GraphicImage') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- $data['yd'] = $convrt_arr[0];
- break;
- }
- foreach ($xml->xpath('//DocumentImage') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- $data['fp'] = $convrt_arr[0];
- break;
- }
- if(isset($data['yd']))
- {
- return array('c'=>1,'data'=>$data);exit;
- }
- else
- {
- $error = '';
- foreach ($xml->xpath('//Notification') as $item)
- {
- $errorjson = json_encode($item);
- $errorjson = json_decode($errorjson, true);
- $error .= isset($errorjson['Message'])?$errorjson['Message'].';':'错误信息获取失败;';
- }
- if(isset($error))
- {
- return array('c'=>2,'data'=>$error);exit;
- }
- else
- {
- return array('c'=>2,'data'=>'获取数据失败,未知错误!');exit;
- }
- }
- /**
-
- $ch = curl_init();
- $url = 'http://z.wepolicy.cn/dhlhz.php';
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- //设置post数据
- $post = array();
- $post['data'] = $json;
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
- $res = curl_exec($ch);
- curl_close($ch);
- $data = json_decode($res,true);
-
- if(isset($data['yd']))
- {
- return array('c'=>1,'data'=>$data);exit;
- }
- else
- {
- if(isset($data['$error']))
- {
- return array('c'=>2,'data'=>$error);exit;
- }
- else
- {
- return array('c'=>2,'data'=>'获取数据失败,未知错误!');exit;
- }
- }
- **/
- }
-
-
- public function get_data2($data)//旧版API
- {
- if($data['pay'] == 1)
- {
- $data['pay'] == 'PayPal';
- }
- else if($data['pay'] == 2)
- {
- $data['pay'] == 'Western Union';
- }
- else if($data['pay'] == 3)
- {
- $data['pay'] == '微信';
- }
- else if($data['pay'] == 4)
- {
- $data['pay'] == '支付宝';
- }
- else if($data['pay'] == 5)
- {
- $data['pay'] == '银行转账';
- }
- else if($data['pay'] == 6)
- {
- $data['pay'] == '现金收款';
- }
- else if($data['pay'] == 7)
- {
- $data['pay'] == 'PingPong金融';
- }
- $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI');
- $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
- $data['province'] = trim($data['province'],' ');
- if(isset($ToState[strtolower($data['province'])]))
- {
- $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
- $data['province'] = $dataprovince;
- }
- $sid = '606946403';
- $username = 'longyitechnCN';
- $password = 'S#5uZ#4vZ$2b';
- $xmend = "\n";
- $json = "<?xml version='1.0' encoding='UTF-8'?>".$xmend;
- $json .= '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ship="http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/ShipmentMsgRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">'.$xmend;
- $json .= '<soapenv:Header>'.$xmend;
- $json .= '<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:mustUnderstand="1">'.$xmend;
- $json .= '<wsse:UsernameToken wsu:Id="">'.$xmend;
- $json .= '<wsse:Username>'.$username.'</wsse:Username>'.$xmend;
- $json .= "<wsse:Password Type='PasswordText'>".$password."</wsse:Password>".$xmend;
- $json .= "<wsse:Nonce EncodingType='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'> eUYebYfsjztETJ4Urt8AJw ==</wsse:Nonce>".$xmend;
- $json .= '<wsu:Created>'.date('c').'</wsu:Created>'.$xmend;
- $json .= '</wsse:UsernameToken>'.$xmend;
- $json .= '</wsse:Security>'.$xmend;
- $json .= '</soapenv:Header>'.$xmend;
- $json .= '<soapenv:Body>'.$xmend;
- $json .= '<ship:ShipmentRequest>'.$xmend;
- $json .= '<Request>'.$xmend;
- $json .= '<ServiceHeader>'.$xmend;
- $json .= '<MessageTime>'.date('c').'</MessageTime>'.$xmend;//发送请求的时间
- $json .= '<MessageReference>'.time().time().rand(10000000,99999999).'</MessageReference>'.$xmend;//报文唯一标识
- $json .= '<WebstorePlatform>LYERP</WebstorePlatform>'.$xmend;//客户网店平台名称
- $json .= '<WebstorePlatformVersion>LY_V1.0.0</WebstorePlatformVersion>'.$xmend;//客户网店平台版本号
- $json .= '<ShippingSystemPlatform>LYERP</ShippingSystemPlatform>'.$xmend;//客户发件系统名称
- $json .= '<ShippingSystemPlatformVersion>LY_V1.0.0</ShippingSystemPlatformVersion>'.$xmend;//客户发件系统版本号
- $json .= '<PlugIn>LYERP</PlugIn>'.$xmend;//客户系统插件名称
- $json .= '<PlugInVersion>LY_V1.0.0</PlugInVersion>'.$xmend;//插件版本号
- $json .= '</ServiceHeader>'.$xmend;
- $json .= '</Request>'.$xmend;
- /** 请求装运信息 **/
- $json .= '<RequestedShipment>'.$xmend;
- /** 运单输出 **/
- $json .= '<ShipmentInfo>'.$xmend;
- $json .= '<DropOffType>REGULAR_PICKUP</DropOffType>'.$xmend;//取件类型 REGULAR_PICKUP不预约取件,REQUEST_COURIER预约取件
- $json .= '<ServiceType>P</ServiceType>'.$xmend;//产品代码,普通包裹:P,正午特派包裹:Y
- $json .= '<LocalServiceType>P</LocalServiceType>'.$xmend;//与ServiceType一致,可不保留
- $json .= '<Billing>'.$xmend;
- $json .= '<ShipperAccountNumber>'.$sid.'</ShipperAccountNumber>'.$xmend;//账号
- $json .= '<ShippingPaymentType>S</ShippingPaymentType>'.$xmend;//支付方式S--发件人,R--收件人,T--第三方
- $json .= '<BillingAccountNumber>'.$sid.'</BillingAccountNumber>'.$xmend;//DHL付款账号,当ShippingPaymentType为R或T时,此项为必填项
- $json .= '</Billing>'.$xmend;
- $json .= '<SpecialServices>'.$xmend;
- $json .= '<Service>'.$xmend;
- $json .= '<ServiceType>WY</ServiceType>'.$xmend;//WY无纸化贸易,DTP服务代码DD,PLT服务代码WY
- $json .= '</Service>'.$xmend;
- if($data['bx'] > 0)
- {
- $json .= '<Service>'.$xmend;
- $json .= '<ServiceType>II</ServiceType>'.$xmend;//II购买保险
- $json .= '<ServiceValue>'.$data['bx'].'</ServiceValue>'.$xmend;//保险金额
- $json .= '<CurrencyCode>USD</CurrencyCode>'.$xmend;//保险货币
- $json .= '</Service>'.$xmend;
- }
- $json .= '</SpecialServices>'.$xmend;
- $json .= '<Currency>USD</Currency>'.$xmend;//运费币种
- $json .= '<UnitOfMeasurement>SI</UnitOfMeasurement>'.$xmend;//重量单位SI表示千克和厘米,SU表示英镑和英寸
- $json .= '<ShipmentReferences>'.$xmend;
- $json .= '<ShipmentReference>'.$xmend;
- $json .= '<ShipmentReference>'.$data['number'].'</ShipmentReference>'.$xmend;
- $json .= '</ShipmentReference>'.$xmend;
- $json .= '</ShipmentReferences>'.$xmend;
- $json .= '<LabelType>PDF</LabelType>'.$xmend;//面单输出格式
- $json .= '<LabelTemplate>ARCH_8X4</LabelTemplate>'.$xmend;//面单规格:ECOM26_84_A4_001是A4,ECOM26_84_A4_001是标签
- $json .= '<ArchiveLabelTemplate>ARCH_8x4</ArchiveLabelTemplate>'.$xmend;//ARCH_8X4_A4_002:A4纸运单,ARCH_8X4:标签运单Request中未添加该元素时,将默认为标签运单
- $json .= '<CustomsInvoiceTemplate>COMMERCIAL_INVOICE_03</CustomsInvoiceTemplate>'.$xmend;//海关发票模板
- $json .= '<PaperlessTradeEnabled>true</PaperlessTradeEnabled>'.$xmend;//启用无纸贸易
- $json .= '<LabelOptions>'.$xmend;
- $json .= '<PrinterDPI>200</PrinterDPI>'.$xmend;
- $json .= '<RequestWaybillDocument>N</RequestWaybillDocument>'.$xmend;//是否打印运单WaybillDoc联
- $json .= '<HideAccountInWaybillDocument>N</HideAccountInWaybillDocument>'.$xmend;//是否隐藏付款账号,Y隐藏,N不隐藏
- $json .= '<NumberOfWaybillDocumentCopies>1</NumberOfWaybillDocumentCopies>'.$xmend;//打印数量
- $json .= '<RequestDHLCustomsInvoice>Y</RequestDHLCustomsInvoice>'.$xmend;//是否需要发票
- $json .= '<DHLCustomsInvoiceLanguageCode>eng</DHLCustomsInvoiceLanguageCode>'.$xmend;//海关发票语言代码
- $json .= '<DHLCustomsInvoiceType>COMMERCIAL_INVOICE</DHLCustomsInvoiceType>'.$xmend;//海关发票类型
- $json .= '</LabelOptions>'.$xmend;
- $json .= '</ShipmentInfo>'.$xmend;
- $json .= '<ShipTimestamp>'.date('Y-m-d',time()+19*3600).'T'.date('H:i:s',time()+19*3600).'GMT+08:00</ShipTimestamp>'.$xmend;//发货时间(预约取货时间开始)
- $json .= '<PaymentInfo>DAP</PaymentInfo>'.$xmend;//付款信息 !*
- /** 包裹和文件 **/
- $json .= '<InternationalDetail>'.$xmend;
- $json .= '<Commodities>'.$xmend;
- $json .= '<Description>'.$data['sbpm'].'</Description>'.$xmend;//商品描述,写报关货物内容,品名
- $json .= '<CustomsValue>'.$data['zsbjz'].'</CustomsValue>'.$xmend;//申报价值
- $json .= '</Commodities>'.$xmend;
- $json .= '<Content>NON_DOCUMENTS</Content>'.$xmend;//NON_DOCUMENTS为包裹,DOCUMENTS为文件
- $json .= '<ExportDeclaration>'.$xmend;
- //循环开始
- $json .= '<ExportLineItems>'.$xmend;
- //(1)
- $json .= '<ExportLineItem>'.$xmend;
- $json .= '<CommodityCode>'.$data['hgbm'].'</CommodityCode>'.$xmend;//海关编码
- $json .= '<ExportReasonType>PERMANENT</ExportReasonType>'.$xmend;//出口原因可选值如下: - ‘PERMANENT’- ‘TEMPORARY’- ‘RETURN’
- $json .= '<ItemNumber>1</ItemNumber>'.$xmend;//物品序号
- $json .= '<Quantity>'.$data['ts'].'</Quantity>'.$xmend;//数量
- $json .= '<QuantityUnitOfMeasurement>PCS</QuantityUnitOfMeasurement>'.$xmend;//数量单位,条
- $json .= '<ItemDescription>'.$data['sbpm'].'</ItemDescription>'.$xmend;//商品描述
- $json .= '<UnitPrice>'.$data['dtsbjz'].'</UnitPrice>'.$xmend;//单条申报价
- $json .= '<NetWeight>'.$data['zzl'].'</NetWeight>'.$xmend;//净重
- $json .= '<GrossWeight>'.$data['zzl'].'</GrossWeight>'.$xmend;//总重量
- $json .= '<ManufacturingCountryCode>CN</ManufacturingCountryCode>'.$xmend;//制造国家代码
- $json .= '</ExportLineItem>'.$xmend;
- //循环结束
- $json .= '</ExportLineItems>'.$xmend;
- $json .= '<InvoiceDate>'.date('Y-m-d',time()).'</InvoiceDate>'.$xmend;//发票日期
- $json .= '<InvoiceNumber>'.$data['paypal'].' '.$data['pay'].'</InvoiceNumber>'.$xmend;//发票号码
- $json .= '<Remarks>'.$xmend;
- $json .= '<Remark>'.$xmend;
- $json .= '<RemarkDescription>'.$data['number'].'</RemarkDescription>'.$xmend;//备注说明
- $json .= '</Remark>'.$xmend;
- $json .= '</Remarks>'.$xmend;
- $json .= '</ExportDeclaration>'.$xmend;
- $json .= '</InternationalDetail>'.$xmend;
- $json .= '<Ship>'.$xmend;
- $json .= '<Shipper>'.$xmend;
- $json .= '<Contact>'.$xmend;
- $json .= '<PersonName>He Chong Bo</PersonName>'.$xmend;//发货人 '.$data['warehouse']['company'].'
- $json .= '<CompanyName>Kun Peng Fazhipin</CompanyName>'.$xmend;//'.$data['warehouse']['company'].'
- $json .= '<PhoneNumber>15939964739</PhoneNumber>'.$xmend;
- $json .= '<EmailAddress>test@test.com</EmailAddress>'.$xmend;//发件人电子邮件
- $json .= '<MobilePhoneNumber>256345673</MobilePhoneNumber>'.$xmend;//发件人固话
- $json .= '</Contact>'.$xmend;
- $json .= '<Address>'.$xmend;
- $json .= '<StreetLines>4703,building C,</StreetLines>'.$xmend;//'.$data['warehouse']['address'].'
- $json .= '<StreetLines2>bodi center,ningwei street</StreetLines2>'.$xmend;//'.$data['warehouse']['address2'].'
- //$json .= '<StreetLines3></StreetLines3>'.$xmend;
- $json .= '<City>Hang Zhou</City>'.$xmend;//'.$data['warehouse']['city'].'
- $json .= '<StateOrProvinceCode>Zhe Jiang</StateOrProvinceCode>'.$xmend;//'.$data['warehouse']['province'].'
- $json .= '<PostalCode>310000</PostalCode>'.$xmend;//'.$data['warehouse']['zipcode'].'
- $json .= '<CountryCode>'.$data['warehouse']['lb'].'</CountryCode>'.$xmend;//国家代码
- $json .= '</Address>'.$xmend;
- $json .= '</Shipper>'.$xmend;
- $json .= '<Recipient>'.$xmend;
- $json .= '<Contact>'.$xmend;
- $json .= '<PersonName>'.$data['name'].'</PersonName>'.$xmend;//收货人
- $json .= '<CompanyName>'.$data['client'].'</CompanyName>'.$xmend;
- $json .= '<PhoneNumber>'.$data['phone'].'</PhoneNumber>'.$xmend;
- //$json .= '<EmailAddress></EmailAddress>'.$xmend;//发件人电子邮件
- //$json .= '<MobilePhoneNumber></MobilePhoneNumber>'.$xmend;//发件人固话
- $json .= '</Contact>'.$xmend;
- $json .= '<Address>'.$xmend;
- if(strlen($data['address'].$data['address2']) > 44)
- {
- $adl = $data['address'].$data['address2'];
- $adl1 = substr($adl,0,44);//截取44字符前内容
- $adlnum = strripos($adl1," ");//查找最后一次出现空格位置
- $adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
- $adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
- $json .= '<StreetLines>'.$adl1.'</StreetLines>'.$xmend;//收货人地址1
- $json .= '<StreetLines2>'.$adl2.'</StreetLines2>'.$xmend;//收货人地址2
- }
- else
- {
- $json .= '<StreetLines>'.$data['address'].$data['address2'].'</StreetLines>'.$xmend;//收货人地址
- }
- //$json .= '<StreetLines3></StreetLines3>'.$xmend;
- $json .= '<City>'.$data['city'].'</City>'.$xmend;
- if($data['lb'] == 'US')
- {
- $json .= '<StateOrProvinceCode>'.$data['province'].'</StateOrProvinceCode>'.$xmend;
- }
- $json .= '<PostalCode>'.$data['zipcode'].'</PostalCode>'.$xmend;
- $json .= '<CountryCode>'.$data['lb'].'</CountryCode>'.$xmend;//国家代码
- $json .= '</Address>'.$xmend;
- $json .= '</Recipient>'.$xmend;
- $json .= '</Ship>'.$xmend;
-
- $json .= '<Packages>'.$xmend;
- //多箱这里循环
- $json .= '<RequestedPackages number="'.$data['zjs'].'">'.$xmend;
- $json .= '<Weight>'.$data['zzl'].'</Weight>'.$xmend;
- $json .= '<Dimensions>'.$xmend;
- $json .= '<Length>5</Length>'.$xmend;
- $json .= '<Width>15</Width>'.$xmend;
- $json .= '<Height>3</Height>'.$xmend;
- $json .= '</Dimensions>'.$xmend;
- $json .= '<CustomerReferences>'.$data['number'].'</CustomerReferences>'.$xmend;
- $json .= '</RequestedPackages>'.$xmend;
- $json .= '</Packages>'.$xmend;
- //循环结束
- $json .= '</RequestedShipment>'.$xmend;
- $json .= '</ship:ShipmentRequest>'.$xmend;
- $json .= '</soapenv:Body>'.$xmend;
- $json .= '</soapenv:Envelope>'.$xmend;
-
- /**
- $ch = curl_init();
- //curl_setopt($ch, CURLOPT_URL,'https://wsbexpress.dhl.com:443/sndpt/expressRateBook');
- curl_setopt($ch, CURLOPT_URL,'https://wsbexpress.dhl.com:443/gbl/expressRateBook');
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:text/xml; charset=utf-8"));
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- $data = curl_exec($ch);
- curl_close($ch);
- $xml = simplexml_load_string($data);
- $xml->registerXPathNamespace('shipresp', 'http://scxgxtt.phx-dc.dhl.com/euExpressRateBook/ShipmentMsgResponse');
- $data = array();
- foreach ($xml->xpath('//ShipmentIdentificationNumber') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- $data['waybill'] = $convrt_arr[0];
- break;
- }
- foreach ($xml->xpath('//GraphicImage') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- $data['yd'] = $convrt_arr[0];
- break;
- }
- foreach ($xml->xpath('//DocumentImage') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- $data['fp'] = $convrt_arr[0];
- break;
- }
- if(isset($data['yd']))
- {
- return array('c'=>1,'data'=>$data);exit;
- }
- else
- {
- $error = '';
- foreach ($xml->xpath('//Notification') as $item)
- {
- $errorjson = json_encode($item);
- $errorjson = json_decode($errorjson, true);
- $error .= isset($errorjson['Message'])?$errorjson['Message'].';':'错误信息获取失败;';
- }
- if(isset($error))
- {
- return array('c'=>2,'data'=>$error);exit;
- }
- else
- {
- return array('c'=>2,'data'=>'获取数据失败,未知错误!');exit;
- }
- }
- **/
-
- $ch = curl_init();
- $url = 'http://z.wepolicy.cn/dhlhz.php';
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- //设置post数据
- $post = array();
- $post['data'] = $json;
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
- $res = curl_exec($ch);
- curl_close($ch);
- $data = json_decode($res,true);
-
- if(isset($data['yd']))
- {
- return array('c'=>1,'data'=>$data);exit;
- }
- else
- {
- if(isset($data['$error']))
- {
- return array('c'=>2,'data'=>$error);exit;
- }
- else
- {
- return array('c'=>2,'data'=>'获取数据失败,未知错误!');exit;
- }
- }
- }
-
- public function get_epod($data)
- {
- $sid = '606946403';
- $username = 'longyitechnCN';
- $password = 'S#5uZ#4vZ$2b';
- $xmend = "\n";
- $xml = '<?xml version="1.0" encoding="UTF-8"?>'.$xmend;
- $xml .= '<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="glDHLExpressePOD/providers/DocumentRetrieve" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">'.$xmend;
- $xml .= '<SOAP-ENV:Header>'.$xmend;
- $xml .= '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'.$xmend;
- $xml .= '<wsse:UsernameToken wsu:Id="">'.$xmend;
- $xml .= '<wsse:Username>'.$username.'</wsse:Username>'.$xmend;
- $xml .= "<wsse:Password Type='PasswordText'>".$password."</wsse:Password>".$xmend;
- $xml .= "<wsse:Nonce EncodingType=''></wsse:Nonce>".$xmend;
- $xml .= '<wsu:Created>'.date('c').'</wsu:Created>'.$xmend;
- $xml .= '</wsse:UsernameToken>'.$xmend;
- $xml .= '</wsse:Security>'.$xmend;
- $xml .= '</SOAP-ENV:Header>'.$xmend;
- $xml .= '<SOAP-ENV:Body>'.$xmend;
- $xml .= '<tns:shipmentDocumentRetrieveReq>'.$xmend;
- $xml .= '<MSG>'.$xmend;
- $xml .= '<Hdr Dtm="'.date('c').'" Id="'.time().rand(100,999).'" Ver="1.038">'.$xmend;
- $xml .= '<Sndr AppCd="DCGAP" AppNm="DCGAP"/>'.$xmend;
- $xml .= '</Hdr>'.$xmend;
- $xml .= '<Bd>'.$xmend;
- $xml .= '<Shp Id="'.$data['waybill'].'">'.$xmend;
- $xml .= '<ShpTr>'.$xmend;
- $xml .= '<SCDtl AccNo="'.$sid.'" CRlTyCd="PY"/>'.$xmend;
- $xml .= '</ShpTr>'.$xmend;
- $xml .= '<ShpInDoc>'.$xmend;
- $xml .= '<SDoc DocTyCd="POD"/>'.$xmend;
- $xml .= '</ShpInDoc>'.$xmend;
- $xml .= '</Shp>'.$xmend;
- $xml .= '<GenrcRq>'.$xmend;
- $xml .= '<GenrcRqCritr TyCd="IMG_CONTENT" Val="epod-detail"/>'.$xmend;
- $xml .= '<GenrcRqCritr TyCd="IMG_FORMAT" Val="PDF"/>'.$xmend;
- $xml .= '<GenrcRqCritr TyCd="DOC_RND_REQ" Val="true"/>'.$xmend;
- $xml .= '<GenrcRqCritr TyCd="DUPL_HANDL" Val="CORE_WB_NO"/>'.$xmend;
- $xml .= '<GenrcRqCritr TyCd="SORT_BY" Val="$INGEST_DATE,D"/>'.$xmend;
- $xml .= '<GenrcRqCritr TyCd="LANGUAGE" Val="zh"/>'.$xmend;
- $xml .= '</GenrcRq>'.$xmend;
- $xml .= '</Bd>'.$xmend;
- $xml .= '</MSG>'.$xmend;
- $xml .= '</tns:shipmentDocumentRetrieveReq>'.$xmend;
- $xml .= '</SOAP-ENV:Body>'.$xmend;
- $xml .= '</SOAP-ENV:Envelope>'.$xmend;
- //echo $xml;exit;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,'https://wsbexpress.dhl.com:443/gbl/getePOD');
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type:text/xml; charset=utf-8"));
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
- $data = curl_exec($ch);
- curl_close($ch);
- //header("Content-type: application/xml");
- $xml = simplexml_load_string($data);
- $xml->registerXPathNamespace('tns','http://scxgxtt.phx-dc.dhl.com/glDHLExpressePOD/providers/DocumentRetrieve');
- if($xml->xpath('//Img'))
- {
- foreach ($xml->xpath('//Img') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- return array('c'=>1,'d'=>$convrt_arr['@attributes']['Img']);
- }
- }
- else
- {
- foreach ($xml->xpath('//ErrMsgDtl ') as $item)
- {
- $json = json_encode($item);
- $convrt_arr = json_decode($json, true);
- return array('c'=>2,'d'=>$convrt_arr['@attributes']['DtlDsc']);
- }
- }
- }
-
- public function _a($data)
- {
- $token = $this->c();
- $file_header = array(
- 'x-request-id: 606946403',
- 'Authorization: '.$token,
- 'Content-Type: application/json'
- );
- $ch = curl_init();
- $url = 'https://webhub.cndhl.com/dps/dps-declaration-api/api/declare/submit-declare';
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $file_header);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
- //设置post数据
-
-
- $post = array();
- $post['decMessage']['decHead']['iEFlag']="E";
- $post['decMessage']['decHead']['tradeName']="杭州龙熠科技有限公司";
- $post['decMessage']['decHead']['tradeCoScc']="91330106MA2GMD3N8R";
- $post['decMessage']['decHead']['tradeCode']="3316960A6A";
- $post['decMessage']['decHead']['ownerName']="杭州龙熠科技有限公司";
- $post['decMessage']['decHead']['ownerCodeScc']="91330106MA2GMD3N8R";
- $post['decMessage']['decHead']['tradeMode']="3010";
- $post['decMessage']['decHead']['transMode']="2";
- $post['decMessage']['decHead']['cutMode']="101";
- $post['decMessage']['decHead']['feeMark']="3";
- $post['decMessage']['decHead']['feeRate']="10";
- $post['decMessage']['decHead']['feeCurr']="USD";
-
- $post['decMessage']['decLists']['decList'][0]['gNo']="1";
- $post['decMessage']['decLists']['decList'][0]['declGoodsEname']=$data['sbpm'];//申报品名
- $post['decMessage']['decLists']['decList'][0]['gName']=$data['zwpm'];//中文品名
- $post['decMessage']['decLists']['decList'][0]['codeTs']=$data['hgbm'];//海关编码
- $post['decMessage']['decLists']['decList'][0]['gModel']="0|2|假发|化纤";
- $post['decMessage']['decLists']['decList'][0]['gQty']=$data['ts'];//数量
- $post['decMessage']['decLists']['decList'][0]['gUnit']="007";
- $post['decMessage']['decLists']['decList'][0]['declPrice']=$data['dtsbjz'];//申报单价
- $post['decMessage']['decLists']['decList'][0]['declTotal']=$data['zsbjz'];//申报总价
- $post['decMessage']['decLists']['decList'][0]['tradeCurr']="USD";
- $post['decMessage']['decLists']['decList'][0]['firstQty']="0.10000";
- $post['decMessage']['decLists']['decList'][0]['firstUnit']="035";
- $post['decMessage']['decLists']['decList'][0]['goodsBrand']="无";
- $post['decMessage']['decLists']['decList'][0]['dutyMode']="1";
- $post['decMessage']['decLists']['decList'][0]['originCountry']="CHN";
-
- $post['decMessage']['msgHead']['action']="A";
- $post['decMessage']['msgHead']['awbGenDtm']= date("Y-m-d H:i:s",time()-3600);
- $post['decMessage']['msgHead']['awbNo']=$data['waybill'];//运单号
- $post['decMessage']['msgHead']['declareType']="C";
- $post['decMessage']['msgHead']['msgGenDtm']=date("Y-m-d H:i:s",time());
- $post['decMessage']['msgHead']['msgId']="7b67817a-9c81-412d-bedd-10a65ac22508";
- $post['decMessage']['msgHead']['version']="1.0";
-
-
- $data = json_encode($post);
- curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
- $res = curl_exec($ch);
- curl_close($ch);
- $resp = json_decode($res,true);
-
-
- echo "<pre>";
- print_r($resp);
- }
-
- public function c()
- {
- $token_header = array(
- 'x-request-id: 606946403',
- 'Content-Type: application/json'
- );
- $ch = curl_init();
- $url = 'https://webhub.cndhl.com/dps/dps-auth-server/api/gateway-token/generate';
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $token_header);
- curl_setopt($ch,CURLOPT_HEADER,0);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
- //设置post数据
- $post = array();
- $post['consumerCode'] = 'T_mkfsq4ez3w';
- $post['key'] = '8BsPOT:Sib_Vc*$=';
- $data = json_encode($post);
- curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
- $res = curl_exec($ch);
- curl_close($ch);
- $resp = json_decode($res,true);
- $token = $resp['result']['token'];
- return $token;
- }
- } //end class
|