Model_fedex_cby.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <?php
  2. class Model_Fedex_cby extends Lin_Model {
  3. function __construct(){
  4. parent::__construct();
  5. }
  6. public function get_data($data)
  7. {
  8. $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');
  9. $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
  10. $data['province'] = trim($data['province'],' ');
  11. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  12. $data['province'] = $dataprovince;
  13. //your account details here
  14. $key = 'L7Vtg0uUP0BxgNfp';
  15. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  16. $AccountNumber = '644155250';
  17. $MeterNumber = '250140772';
  18. $xml = '<?xml version="1.0" encoding="UTF-8"?>';
  19. $xml.='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v23="http://fedex.com/ws/ship/v23">';
  20. $xml.='<soapenv:Header/>';
  21. $xml.='<soapenv:Body>';
  22. $xml.='<v23:ProcessShipmentRequest>';
  23. $xml.='<v23:WebAuthenticationDetail>';
  24. $xml.='<v23:ParentCredential>';
  25. $xml.='<v23:Key>'.$key.'</v23:Key>';
  26. $xml.='<v23:Password>'.$password.'</v23:Password>';
  27. $xml.='</v23:ParentCredential>';
  28. $xml.='<v23:UserCredential>';
  29. $xml.='<v23:Key>'.$key.'</v23:Key>';
  30. $xml.='<v23:Password>'.$password.'</v23:Password>';
  31. $xml.='</v23:UserCredential>';
  32. $xml.='</v23:WebAuthenticationDetail>';
  33. $xml.='<v23:ClientDetail>';
  34. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  35. $xml.='<v23:MeterNumber>'.$MeterNumber.'</v23:MeterNumber>';
  36. $xml.='</v23:ClientDetail>';
  37. $xml.='<v23:TransactionDetail>';
  38. //$xml.='<v23:CustomerTransactionId>Ship_International_basic</v23:CustomerTransactionId>';
  39. $xml.='</v23:TransactionDetail>';
  40. $xml.='<v23:Version>';
  41. $xml.='<v23:ServiceId>ship</v23:ServiceId>';
  42. $xml.='<v23:Major>23</v23:Major>';
  43. $xml.='<v23:Intermediate>0</v23:Intermediate>';
  44. $xml.='<v23:Minor>0</v23:Minor>';
  45. $xml.='</v23:Version>';
  46. $xml.='<v23:RequestedShipment>';
  47. $xml.='<v23:ShipTimestamp>'.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.'</v23:ShipTimestamp>';
  48. $xml.='<v23:DropoffType>REGULAR_PICKUP</v23:DropoffType>';
  49. $xml.='<v23:ServiceType>INTERNATIONAL_PRIORITY</v23:ServiceType>';//优先。INTERNATIONAL_ECONOMY经济
  50. //超过重量需要换包装,现在不设置,超出也按0.4走
  51. if($data['zzl'] < '0.5')
  52. {
  53. $xml.='<v23:PackagingType>FEDEX_PAK</v23:PackagingType>';
  54. }
  55. else
  56. {
  57. $xml.='<v23:PackagingType>FEDEX_BOX</v23:PackagingType>';
  58. }
  59. $xml.='<v23:Shipper>';//发货人信息开始
  60. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  61. $xml.='<v23:Contact>';
  62. $xml.='<v23:PersonName>'.$data['warehouse']['company'].'</v23:PersonName>';//$data['warehouse']['company']
  63. $xml.='<v23:CompanyName>'.$data['warehouse']['company'].'</v23:CompanyName>';//$data['warehouse']['company']
  64. $xml.='<v23:PhoneNumber>'.$data['warehouse']['phone'].'</v23:PhoneNumber>';//$data['warehouse']['phone']
  65. //$xml.='<v23:EMailAddress>'.$data['warehouse']['name'].'</v23:EMailAddress>';
  66. $xml.='</v23:Contact>';
  67. $xml.='<v23:Address>';
  68. $xml.='<v23:StreetLines>4703,building C,bodi center,ningwei street</v23:StreetLines>';//$data['warehouse']['address']
  69. $xml.='<v23:City>'.$data['warehouse']['city'].'</v23:City>';//$data['warehouse']['city']
  70. //$xml.='<v23:StateOrProvinceCode>TN</v23:StateOrProvinceCode>';
  71. $xml.='<v23:PostalCode>450016</v23:PostalCode>';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016
  72. $xml.='<v23:CountryCode>'.$data['warehouse']['lb'].'</v23:CountryCode>';
  73. $xml.='</v23:Address>';
  74. $xml.='</v23:Shipper>';
  75. $xml.='<v23:Recipient>';//收货人信息开始
  76. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  77. $xml.='<v23:Contact>';
  78. $xml.='<v23:PersonName>'.$data['name'].'</v23:PersonName>';
  79. $xml.='<v23:CompanyName>'.$data['name'].'</v23:CompanyName>';
  80. $xml.='<v23:PhoneNumber>'.$data['phone'].'</v23:PhoneNumber>';
  81. //$xml.='<v23:EMailAddress>'.$data['name'].'</v23:EMailAddress>';
  82. $xml.='</v23:Contact>';
  83. $xml.='<v23:Address>';
  84. $xml.='<v23:StreetLines>'.$data['address'].'</v23:StreetLines>';
  85. $xml.='<v23:StreetLines>'.$data['address2'].'</v23:StreetLines>';
  86. $xml.='<v23:City>'.$data['city'].'</v23:City>';
  87. $xml.='<v23:StateOrProvinceCode>'.$data['province'].'</v23:StateOrProvinceCode>';
  88. $xml.='<v23:PostalCode>'.$data['zipcode'].'</v23:PostalCode>';
  89. $xml.='<v23:CountryCode>'.$data['lb'].'</v23:CountryCode>';
  90. $xml.='</v23:Address>';
  91. $xml.='</v23:Recipient>';
  92. $xml.='<v23:ShippingChargesPayment>';
  93. $xml.='<v23:PaymentType>SENDER</v23:PaymentType>';
  94. $xml.='<v23:Payor>';
  95. $xml.='<v23:ResponsibleParty>';
  96. $xml.='<v23:AccountNumber>'.$AccountNumber.'</v23:AccountNumber>';
  97. $xml.='<v23:Contact>';
  98. $xml.='<v23:PersonName>He Cong</v23:PersonName>';
  99. //$xml.='<v23:EMailAddress></v23:EMailAddress>';
  100. $xml.='</v23:Contact>';
  101. $xml.='</v23:ResponsibleParty>';
  102. $xml.='</v23:Payor>';
  103. $xml.='</v23:ShippingChargesPayment>';
  104. //ETD开始
  105. $xml.='<v23:SpecialServicesRequested>';
  106. $xml.='<v23:SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</v23:SpecialServiceTypes>';
  107. $xml.='<v23:EtdDetail>';
  108. $xml.='<v23:RequestedDocumentCopies>COMMERCIAL_INVOICE</v23:RequestedDocumentCopies>';
  109. $xml.='</v23:EtdDetail>';
  110. $xml.='</v23:SpecialServicesRequested>';
  111. //ETD结束
  112. $xml.='<v23:CustomsClearanceDetail>';
  113. $xml.='<v23:DutiesPayment>';
  114. $xml.='<v23:PaymentType>RECIPIENT</v23:PaymentType>';
  115. $xml.='<v23:Payor>';
  116. $xml.='<v23:ResponsibleParty>';
  117. $xml.='<v23:AccountNumber></v23:AccountNumber>';
  118. //$xml.='<v23:Tins>';
  119. //$xml.='<v23:TinType>BUSINESS_STATE</v23:TinType>';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE
  120. //$xml.='<v23:Number>213456</v23:Number>';//这里填税号
  121. //$xml.='</v23:Tins>';
  122. //$xml.='<v23:Contact>';
  123. //$xml.='<v23:ContactId>12345</v23:ContactId>';
  124. //$xml.='<v23:PersonName>INPUT YOUR INFORMATION</v23:PersonName>';
  125. //$xml.='</v23:Contact>';
  126. $xml.='</v23:ResponsibleParty>';
  127. $xml.='</v23:Payor>';
  128. $xml.='</v23:DutiesPayment>';
  129. $xml.='<v23:DocumentContent>DOCUMENTS_ONLY</v23:DocumentContent>';
  130. $xml.='<v23:CustomsValue>';
  131. $xml.='<v23:Currency>USD</v23:Currency>';
  132. $xml.='<v23:Amount>'.$data['zsbjz'].'</v23:Amount>';
  133. $xml.='</v23:CustomsValue>';
  134. //DESC1---:Commodities循环
  135. $xml.='<v23:Commodities>';
  136. $xml.='<v23:NumberOfPieces>'.$data['zjs'].'</v23:NumberOfPieces>';//件数
  137. $xml.='<v23:Description>'.$data['sbpm'].' HSCODE:67041900</v23:Description>';//描述
  138. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  139. $xml.='<v23:Weight>';//需要填写重量
  140. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  141. $xml.='<v23:Value>0.4</v23:Value>';//重量填写单位为KG $data['zzl']
  142. $xml.='</v23:Weight>';
  143. $xml.='<v23:Quantity>'.$data['ts'].'</v23:Quantity>';//需要填写数量
  144. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  145. $xml.='<v23:UnitPrice>';
  146. $xml.='<v23:Currency>USD</v23:Currency>';
  147. $xml.='<v23:Amount>'.$data['dtsbjz'].'</v23:Amount>';
  148. $xml.='</v23:UnitPrice>';
  149. $xml.='</v23:Commodities>';
  150. /**
  151. //DESC2
  152. $xml.='<v23:Commodities>';
  153. $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
  154. $xml.='<v23:Description>WIGS SYNTHETIC HAIR PRODUCTS</v23:Description>';//描述
  155. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  156. $xml.='<v23:Weight>';//需要填写重量
  157. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  158. $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
  159. $xml.='</v23:Weight>';
  160. $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
  161. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  162. $xml.='<v23:UnitPrice>';
  163. $xml.='<v23:Currency>USD</v23:Currency>';
  164. $xml.='<v23:Amount>0</v23:Amount>';
  165. $xml.='</v23:UnitPrice>';
  166. $xml.='</v23:Commodities>';
  167. //DESC3
  168. $xml.='<v23:Commodities>';
  169. $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
  170. $xml.='<v23:Description>MAKE WOMEN MORE BEAUTIFUL WITH THE HAIR</v23:Description>';//描述
  171. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  172. $xml.='<v23:Weight>';//需要填写重量
  173. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  174. $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
  175. $xml.='</v23:Weight>';
  176. $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
  177. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  178. $xml.='<v23:UnitPrice>';
  179. $xml.='<v23:Currency>USD</v23:Currency>';
  180. $xml.='<v23:Amount>0</v23:Amount>';
  181. $xml.='</v23:UnitPrice>';
  182. $xml.='</v23:Commodities>';
  183. //DESC4
  184. $xml.='<v23:Commodities>';
  185. $xml.='<v23:NumberOfPieces>0</v23:NumberOfPieces>';//件数
  186. $xml.='<v23:Description>MADE IN CHINA</v23:Description>';//描述
  187. $xml.='<v23:CountryOfManufacture>CN</v23:CountryOfManufacture>';
  188. $xml.='<v23:Weight>';//需要填写重量
  189. $xml.='<v23:Units>KG</v23:Units>';//重量:磅
  190. $xml.='<v23:Value>0.0001</v23:Value>';//重量填写单位为KG
  191. $xml.='</v23:Weight>';
  192. $xml.='<v23:Quantity>1</v23:Quantity>';//需要填写数量
  193. $xml.='<v23:QuantityUnits>cm</v23:QuantityUnits>';
  194. $xml.='<v23:UnitPrice>';
  195. $xml.='<v23:Currency>USD</v23:Currency>';
  196. $xml.='<v23:Amount>0</v23:Amount>';
  197. $xml.='</v23:UnitPrice>';
  198. $xml.='</v23:Commodities>';
  199. **/
  200. $xml.='<v23:ExportDetail>';
  201. $xml.='<v23:ExportComplianceStatement>30.37(f)</v23:ExportComplianceStatement>';
  202. $xml.='</v23:ExportDetail>';
  203. $xml.='</v23:CustomsClearanceDetail>';
  204. $xml.='<v23:LabelSpecification>';
  205. $xml.='<v23:LabelFormatType>COMMON2D</v23:LabelFormatType>';
  206. $xml.='<v23:ImageType>PDF</v23:ImageType>';
  207. $xml.='<v23:LabelStockType>STOCK_4X6.75</v23:LabelStockType>';
  208. $xml.='</v23:LabelSpecification>';
  209. //发票参数开始
  210. $xml.='<v23:ShippingDocumentSpecification>';
  211. $xml.='<v23:ShippingDocumentTypes>COMMERCIAL_INVOICE</v23:ShippingDocumentTypes>';
  212. //ETD
  213. $xml.='<v23:CommercialInvoiceDetail>';
  214. $xml.='<v23:Format>';
  215. $xml.='<v23:ImageType>PDF</v23:ImageType>';
  216. $xml.='<v23:StockType>PAPER_LETTER</v23:StockType>';
  217. $xml.='<v23:ProvideInstructions>true</v23:ProvideInstructions>';
  218. $xml.='</v23:Format>';
  219. $xml.='<v23:CustomerImageUsages>';
  220. $xml.='<v23:Type>LETTER_HEAD</v23:Type>';
  221. $xml.='<v23:Id>IMAGE_1</v23:Id>';
  222. $xml.='</v23:CustomerImageUsages>';
  223. $xml.='<v23:CustomerImageUsages>';
  224. $xml.='<v23:Type>SIGNATURE</v23:Type>';
  225. $xml.='<v23:Id>IMAGE_2</v23:Id>';
  226. $xml.='</v23:CustomerImageUsages>';
  227. //ETD
  228. $xml.='</v23:CommercialInvoiceDetail>';
  229. $xml.='</v23:ShippingDocumentSpecification>';
  230. //发票参数结束
  231. $xml.='<v23:RateRequestTypes>LIST</v23:RateRequestTypes>';//费率请求类型
  232. $xml.='<v23:PackageCount>'.$data['zjs'].'</v23:PackageCount>';//包装数量
  233. $xml.='<v23:RequestedPackageLineItems>';
  234. $xml.='<v23:SequenceNumber>1</v23:SequenceNumber>';
  235. $xml.='<v23:Weight>';
  236. $xml.='<v23:Units>KG</v23:Units>';
  237. $xml.='<v23:Value>'.$data['zzl'].'</v23:Value>';
  238. $xml.='</v23:Weight>';
  239. //超过重量需要填尺寸,现在不设置,超出也按0.4走
  240. if($data['zzl'] > '0.4')
  241. {
  242. $xml.='<v23:Dimensions>';
  243. $xml.='<v23:Length>4</v23:Length>';//$data['boxlength']
  244. $xml.='<v23:Width>20</v23:Width>';
  245. $xml.='<v23:Height>30</v23:Height>';
  246. $xml.='<v23:Units>CM</v23:Units>';
  247. $xml.='</v23:Dimensions>';
  248. }
  249. //$xml.='<v23:ItemDescription>Book</v23:ItemDescription>';//阿联酋需要选择
  250. $xml.='<v23:CustomerReferences>';
  251. $xml.='<v23:CustomerReferenceType>CUSTOMER_REFERENCE</v23:CustomerReferenceType>';
  252. $xml.='<v23:Value>'.$data['number'].'</v23:Value>';
  253. $xml.='</v23:CustomerReferences>';
  254. $xml.='</v23:RequestedPackageLineItems>';
  255. $xml.='</v23:RequestedShipment>';
  256. $xml.='</v23:ProcessShipmentRequest>';
  257. $xml.='</soapenv:Body>';
  258. $xml.='</soapenv:Envelope>';
  259. $ch = curl_init();
  260. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
  261. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  262. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  263. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  264. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  265. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  266. curl_setopt($ch, CURLOPT_POST, 1);
  267. $result_xml = curl_exec($ch);
  268. $result_xml = str_replace(array(':','-'), '', $result_xml);
  269. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  270. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber']))
  271. {
  272. $g = array('x'=>'1','waybill'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber'],'label'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['CompletedPackageDetails']['Label']['Parts']['Image'],'invoice'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['ShipmentDocuments']['Parts']['Image']);
  273. }
  274. else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']))
  275. {
  276. $a = '';
  277. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']))
  278. {
  279. $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'];
  280. }
  281. else
  282. {
  283. foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v)
  284. {
  285. $a .= $v['LocalizedMessage'].'--';
  286. }
  287. }
  288. $g = array('x'=>'0','Description'=>$a);
  289. }
  290. else
  291. {
  292. $g = array('x'=>'0','Description'=>'未知错误');
  293. }
  294. return $g;
  295. }
  296. public function get_Upload_signature($id='',$img='')//上传签名图片
  297. {
  298. /**
  299. //一下为旧的测试账号
  300. $key = 'lx0vfuP9eZMXyDdd';
  301. $password = '1e6HFUgU1SxoZ6CpYMXBupqQY';
  302. $AccountNumber = '510087720';
  303. $MeterNumber = '100421603';
  304. **/
  305. //以下为旧的正式账号
  306. /**
  307. $key = 'L7Vtg0uUP0BxgNfp';
  308. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  309. $AccountNumber = '644155250';
  310. $MeterNumber = '250140772';
  311. **/
  312. $key = 'L7Vtg0uUP0BxgNfp';
  313. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  314. $AccountNumber = '644155250';
  315. $MeterNumber = '250140772';
  316. $xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v11="http://fedex.com/ws/uploaddocument/v11">';
  317. $xml.='<soapenv:Header/>';
  318. $xml.='<soapenv:Body>';
  319. $xml.='<v11:UploadImagesRequest>';
  320. $xml.='<v11:WebAuthenticationDetail>';
  321. $xml.='<v11:ParentCredential>';
  322. $xml.='<v11:Key>'.$key.'</v11:Key>';
  323. $xml.='<v11:Password>'.$password.'</v11:Password>';
  324. $xml.='</v11:ParentCredential>';
  325. $xml.='<v11:UserCredential>';
  326. $xml.='<v11:Key>'.$key.'</v11:Key>';
  327. $xml.='<v11:Password>'.$password.'</v11:Password>';
  328. $xml.='</v11:UserCredential>';
  329. $xml.='</v11:WebAuthenticationDetail>';
  330. $xml.='<v11:ClientDetail>';
  331. $xml.='<v11:AccountNumber>'.$AccountNumber.'</v11:AccountNumber>';
  332. $xml.='<v11:MeterNumber>'.$MeterNumber.'</v11:MeterNumber>';
  333. $xml.='</v11:ClientDetail>';
  334. $xml.='<v11:TransactionDetail>';
  335. $xml.='<v11:CustomerTransactionId>UploadImagesRequest_v11</v11:CustomerTransactionId>';
  336. $xml.='</v11:TransactionDetail>';
  337. $xml.='<v11:Version>';
  338. $xml.='<v11:ServiceId>cdus</v11:ServiceId>';
  339. $xml.='<v11:Major>11</v11:Major>';
  340. $xml.='<v11:Intermediate>0</v11:Intermediate>';
  341. $xml.='<v11:Minor>0</v11:Minor>';
  342. $xml.='</v11:Version>';
  343. $xml.='<v11:Images>';
  344. $xml.='<v11:Id>IMAGE_2</v11:Id>';//填IMAGE_1和IMAGE_2,两个都需要传一遍
  345. $xml.='<v11:Image></v11:Image>';//填LOGO 700*50 64编码 不用站长工具,转换错误
  346. $xml.='</v11:Images>';
  347. $xml.='</v11:UploadImagesRequest>';
  348. $xml.='</soapenv:Body>';
  349. $xml.='</soapenv:Envelope>';
  350. $ch = curl_init();
  351. //https://ws.fedex.com:443/web-services 正式
  352. //https://wsbeta.fedex.com:443/web-services 测试
  353. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
  354. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  355. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  356. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  357. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  358. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  359. curl_setopt($ch, CURLOPT_POST, 1);
  360. $result_xml = curl_exec($ch);
  361. $result_xml = str_replace(array(':','-'), '', $result_xml);
  362. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  363. return $values;
  364. }
  365. public function get_logistics($number)//追踪快递
  366. {
  367. $key = 'L7Vtg0uUP0BxgNfp';
  368. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  369. $AccountNumber = '644155250';
  370. $MeterNumber = '250140772';
  371. $xml='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v16="http://fedex.com/ws/track/v16">';
  372. $xml.='<soapenv:Header/>';
  373. $xml.='<soapenv:Body>';
  374. $xml.='<v16:TrackRequest>';
  375. $xml.='<v16:WebAuthenticationDetail>';
  376. $xml.='<v16:ParentCredential>';
  377. $xml.='<v16:Key>'.$key.'</v16:Key>';
  378. $xml.='<v16:Password>'.$password.'</v16:Password>';
  379. $xml.='</v16:ParentCredential>';
  380. $xml.='<v16:UserCredential>';
  381. $xml.='<v16:Key>'.$key.'</v16:Key>';
  382. $xml.='<v16:Password>'.$password.'</v16:Password>';
  383. $xml.='</v16:UserCredential>';
  384. $xml.='</v16:WebAuthenticationDetail>';
  385. $xml.='<v16:ClientDetail>';
  386. $xml.='<v16:AccountNumber>'.$AccountNumber.'</v16:AccountNumber>';
  387. $xml.='<v16:MeterNumber>'.$MeterNumber.'</v16:MeterNumber>';
  388. $xml.='</v16:ClientDetail>';
  389. $xml.='<v16:TransactionDetail>';
  390. $xml.='<v16:CustomerTransactionId>Track By Number_v16</v16:CustomerTransactionId>';
  391. $xml.='<v16:Localization>';
  392. $xml.='<v16:LanguageCode>EN</v16:LanguageCode>';
  393. $xml.='<v16:LocaleCode>US</v16:LocaleCode>';
  394. $xml.='</v16:Localization>';
  395. $xml.='</v16:TransactionDetail>';
  396. $xml.='<v16:Version>';
  397. $xml.='<v16:ServiceId>trck</v16:ServiceId>';
  398. $xml.='<v16:Major>16</v16:Major>';
  399. $xml.='<v16:Intermediate>0</v16:Intermediate>';
  400. $xml.='<v16:Minor>0</v16:Minor>';
  401. $xml.='</v16:Version>';
  402. $xml.='<v16:SelectionDetails>';
  403. $xml.='<v16:CarrierCode>FDXE</v16:CarrierCode>';
  404. $xml.='<v16:PackageIdentifier>';
  405. $xml.='<v16:Type>TRACKING_NUMBER_OR_DOORTAG</v16:Type>';
  406. $xml.='<v16:Value>'.$number['waybill'].'</v16:Value>';
  407. $xml.='</v16:PackageIdentifier>';
  408. $xml.='<v16:ShipmentAccountNumber/>';
  409. $xml.='<v16:SecureSpodAccount/>';
  410. $xml.='<v16:Destination>';
  411. $xml.='<v16:GeographicCoordinates>rates evertitque aequora</v16:GeographicCoordinates>';
  412. $xml.='</v16:Destination>';
  413. $xml.='</v16:SelectionDetails>';
  414. $xml.='</v16:TrackRequest>';
  415. $xml.='</soapenv:Body>';
  416. $xml.='</soapenv:Envelope>';
  417. $ch = curl_init();
  418. //https://ws.fedex.com:443/web-services 正式
  419. //https://wsbeta.fedex.com:443/web-services 测试
  420. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services');
  421. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  422. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  423. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  424. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  425. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  426. curl_setopt($ch, CURLOPT_POST, 1);
  427. $result_xml = curl_exec($ch);
  428. $result_xml = str_replace(array(':','-'), '', $result_xml);
  429. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  430. if($values['SOAPENVBody']['TrackReply']['HighestSeverity'] == 'SUCCESS')//SUCCESS成功,FAILURE失败,ERROR错误,WARNING警告,NOTE注意
  431. {
  432. $zt = isset($values['SOAPENVBody']['TrackReply']['CompletedTrackDetails']['TrackDetails']['StatusDetail']['Description'])?$values['SOAPENVBody']['TrackReply']['CompletedTrackDetails']['TrackDetails']['StatusDetail']['Description']:'cw'; //In transit在途中,At FedEx destination facility配送中,Delivered完成
  433. if($zt == 'In transit')
  434. {
  435. $exstate = 2;
  436. }
  437. else if($zt == 'At FedEx destination facility')
  438. {
  439. $exstate = 3;
  440. }
  441. else if($zt == 'Delivered')
  442. {
  443. $exstate = 4;
  444. }
  445. else
  446. {
  447. $exstate = 0;
  448. }
  449. if($exstate > 0)
  450. {
  451. $content = date('Y-m-d H',time()).'-查询成功';
  452. $list = array('exstate'=>$exstate,'content'=>$content,'f'=>1);//正常可发送站内信
  453. }
  454. else
  455. {
  456. $list = '';
  457. }
  458. }
  459. else
  460. {
  461. $content = date('Y-m-d H',time()).'-查询失败';
  462. $list = array('content'=>$content,'f'=>0);//非正常只更改详情信息
  463. }
  464. return $list;
  465. }
  466. } //end class