Home Backend Development PHP Tutorial Various express inquiries--Api interface_php digest

Various express inquiries--Api interface_php digest

May 16, 2016 pm 07:53 PM
api interface


Authorization successful my key

If you reprint, please indicate the source http://blog.csdn.net/qxs965266509, please pay attention!

Aicha Express API instruction document API address:

Previously: http://api.ickd.cn/?com=[]&nu=[]&id=[]&type=[]&encode=[]&ord=[]&lang=[]

Currently: http://api.ickd.cn/?id=[]&secret=[]&com=[]&nu=[]&type=[]&encode=[]&ord=[]&lang=[]

Parameter description

Field Is it necessary Note that com must have a courier company code (English). The supported courier companies are listed below. nu must have a courier order number, and the length must be greater than 5 digits id
secret must
ID that must be authorized
Authorize KEY, to apply please click Express Query API application method type optional return result type, the values ​​are html | json (default) | text | xmlencode optional gbk (default) | utf8ord optional asc (default) | desc, return results Sorting lang is optionalenReturn English results, currently only supports some express delivery (EMS, SF Express, DHL)Note:When using PHP’s json_decode function, UTF8 encoding must be used. If json_decode appears Failure, please try using UTF8 encoding. Return format: json | text | html | xml
Encoding: GBK| UTF8
Example: {"status":"3","message":"","errCode":"0","data":[{"time":"2013-02-23 17:10","context" :"The recipient Wang Guang of the Fourth Department Company in Zhongshan District, Dalian City, Liaoning Province has received the receipt"},{"time":"2013-02-24 17:59","context":"The company in Dalian City, Liaoning Province has received the receipt "},{"time":"2013-02-24 18:11","context":"The Fourth Department Company of Zhongshan District, Dalian City, Liaoning Province has received the receipt"},{"time":"2013-02-26 07 ; ":"Customer colleagues send and receive family members and have signed for delivery person Zhang Jinda"}],"html":"","mailNo":"7151900624","expTextName":"YTO Express","expSpellName":"yuantong"," update":"1362656241","cache":"186488","ord":"ASC"}Field description Field type Description statusint query result status, 0|1|2|3|4, 0 means query failed, 1 normal, 2 dispatching, 3 signed for, 4 returned, 5 other problems errCodeint error code, 0 no error, 1 order number not Exists, 2 verification code error, 3 link query server failure, 4 internal program error, 5 program execution error, 6 express delivery number format error, 7 express company error, 10 unknown error messagestring error message dataarray progress htmlstring other HTML, this field is not There must be mailNostring courier number expSpellNamestring courier company English code expTextNamestring courier company Chinese name updateint last update time (unix timestamp) cacheint cache time, the difference between the current time and update, the unit is: seconds ordstring sorting, ASC | DESCphp application Example
<script language="javascript"> <&#63;php$id='xxxxxxxxxxxxxxxxx';
//到<a href="http://www.ickd.cn/api/reg.html">http://www.ickd.cn/api/reg.html</a>申请
$url='http://api.ickd.cn/&#63;com=shentong&nu=588035733628&id='.$id; $data=file_get_contents($url); 
//echo "var data='",$data,"'"; &#63;> $(function(){
 var dataObj=<&#63;=$data&#63;>;
//转换为json对象 var html='<tr>'; html+='<th>物流状态:</th>'; 
html+='<td>'; 
if(dataObj.status>0){ 
html+='<table width="520px" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; border-spacing: 0pt;">'; html+='<tr>'; 
html+='<td width="163" style="background-color:#e6f9fa;border:1px solid #75c2ef;font-size:14px;font-weight:bold;height:20px;text-indent:15px;">'; 
html+='时间'; html+='</td>'; 
html+='<td width="354" style="background-color:#e6f9fa;border:1px solid #75c2ef;font-size:14px;font-weight:bold;height:20px;text-indent:15px;">'; html+='地点和跟踪进度'; html+='</td>'; html+='</tr>'; //输出data的子对象变量 $.each(dataObj.data,function(idx,item){  html+='<tr>'; 
html+='<td width="163" style="border:1px solid #dddddd;font-size: 12px;line-height:22px;padding:3px 5px;">';  html+=item.time;// 每条数据的时间  html+='</td>';  html+='<td width="354" style="border:1px solid #dddddd;font-size: 12px;line-height:22px;padding:3px 5px;">';  html+=item.context;// 每条数据的状态  html+='</td>';  html+='</tr>'; }); html+='</table>'; }else{
//查询不到 
html+='<span style="color:#f00">Sorry! '+dataObj.message+'</span>'; }
 html+='</td></tr>'; $("#shipping_detail").append(html);});</script>
Copy after login

If the server has disabled functions such as file_get_contents and fsockopen, you can use the CURL class. The example is as follows:

<&#63;php $id='xxxxxxxxxxxxx';
//API KEY $com='shunfeng';
//快递公司 $nu='123456';
//快递单号 $type='json';
 $encode='utf8'; 
$gateway=sprintf('http://api.ickd.cn/&#63;id=%s&com=%s&nu=%s&encode=%s&type=%s',$id,$com,$nu,$encode,$type); 
$ch=curl_init($gateway); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
curl_setopt($ch,CURLOPT_HEADER,false); $resp=curl_exec($ch); 
$errmsg=curl_error($ch); if($errmsg){ exit($errmsg); } curl_close($ch);
 echo $resp;&#63;>
Copy after login

ASP application example

<%
Response.Charset="gb2312"
Server.ScriptTimeout = 999999999

Dim Retrieval
Dim url,nu,com
com = Request("com")'Company
nu = Request("nu")'Order number

Dim AppKey,SendURL,ResponseTxt
AppKey = "xxxxxxxxxx" 'Please replace XXXXXX with the KEY you applied for at http://www.ickd.cn/reg.html
SendURL="http://api.ickd.cn/?id="&AppKey&"&com="&com&"&nu="&nu&"&type=json&encode=GBK"'If using UTF8, please make sure encode=utf8
'Response.Write SendURL

'Send data
ResponseTxt=fopen(SendURL) '//Function to get source code

'Call the send data component
Function fopen(URL)
Dim objXML
'Set objXML=CreateObject("MSXML2.SERVERXMLHTTP.3.0") 'Call the XMLHTTP component. If the server does not support it, please use one of the following two and try again
Set objXML=Server.CreateObject("Microsoft.XMLHTTP")
'Set objXML=Server.CreateObject("MSXML2.XMLHTTP.4.0")

'objXML.SetTimeouts 5000, 5000, 30000, 10000' The timeout for resolving DNS names, the timeout for establishing a Winsock connection, the timeout for sending data, and the timeout for receiving responses. Unit millisecond
objXML.Open "GET",URL,False 'Get API query data synchronously
objXML.Send() 'Send
If objXML.Readystate<>4 Then 'The status is not 4, error
Response.Write "{status:0,errCode:100,message:'Error getting data'}"
Exit Function
End If
'Readystate attribute returns the current status of the XML file data. The return values ​​are as follows:
'0-UNINITIALIZED: XML object was generated, but no file was loaded.
'1-LOADING: Loading is in progress, but file parsing has not yet begun.
'2-LOADED: Some files have been loaded and parsed, but the object model has not yet taken effect.
'3-INTERACTIVE: Only valid for loaded partial files, in which case the object model is valid but read-only.
'4-COMPLETED: The file has been completely loaded, indicating that the loading is successful.

fopen=objXML.ResponseBody
fopen=BytesToBstr(objXML.ResponseBody)' returns information and uses function definition encoding. If you need to transcode, please select

Set objXML=Nothing'Close
If Err.number<>0 Then
Response.Write "{status:0,errCode:100,message:'Error getting data'}"
Err.Clear
End If
End Function

'Page encoding conversion
Function BytesToBstr(body)
Dim objstream
Set objstream = Server.CreateObject("Adodb.Stream") '//Call adodb.stream component
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "GBK" 'Convert the original default encoding to GB2312 encoding, otherwise directly using XMLHTTP to call a webpage with Chinese characters will result in garbled codes
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function

'Enter query results
Response.Write ResponseTxt
%>

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Common programming paradigms and design patterns in Go language Common programming paradigms and design patterns in Go language Mar 04, 2024 pm 06:06 PM

As a modern and efficient programming language, Go language has rich programming paradigms and design patterns that can help developers write high-quality, maintainable code. This article will introduce common programming paradigms and design patterns in the Go language and provide specific code examples. 1. Object-oriented programming In the Go language, you can use structures and methods to implement object-oriented programming. By defining a structure and binding methods to the structure, the object-oriented features of data encapsulation and behavior binding can be achieved. packagemaini

What are the internal interfaces of a computer motherboard? Recommended introduction to the internal interfaces of a computer motherboard What are the internal interfaces of a computer motherboard? Recommended introduction to the internal interfaces of a computer motherboard Mar 12, 2024 pm 04:34 PM

When we assemble the computer, although the installation process is simple, we often encounter problems in the wiring. Often, users mistakenly plug the power supply line of the CPU radiator into the SYS_FAN. Although the fan can rotate, it may not work when the computer is turned on. There will be an F1 error "CPUFanError", which also causes the CPU cooler to be unable to adjust the speed intelligently. Let's share the common knowledge about the CPU_FAN, SYS_FAN, CHA_FAN, and CPU_OPT interfaces on the computer motherboard. Popular science on the CPU_FAN, SYS_FAN, CHA_FAN, and CPU_OPT interfaces on the computer motherboard 1. CPU_FANCPU_FAN is a dedicated interface for the CPU radiator and works at 12V

How to deal with Laravel API error problems How to deal with Laravel API error problems Mar 06, 2024 pm 05:18 PM

Title: How to deal with Laravel API error problems, specific code examples are needed. When developing Laravel, API errors are often encountered. These errors may come from various reasons such as program code logic errors, database query problems, or external API request failures. How to handle these error reports is a key issue. This article will use specific code examples to demonstrate how to effectively handle Laravel API error reports. 1. Error handling in Laravel

Oracle API Usage Guide: Exploring Data Interface Technology Oracle API Usage Guide: Exploring Data Interface Technology Mar 07, 2024 am 11:12 AM

Oracle is a world-renowned database management system provider, and its API (Application Programming Interface) is a powerful tool that helps developers easily interact and integrate with Oracle databases. In this article, we will delve into the Oracle API usage guide, show readers how to utilize data interface technology during the development process, and provide specific code examples. 1.Oracle

Oracle API integration strategy analysis: achieving seamless communication between systems Oracle API integration strategy analysis: achieving seamless communication between systems Mar 07, 2024 pm 10:09 PM

OracleAPI integration strategy analysis: To achieve seamless communication between systems, specific code examples are required. In today's digital era, internal enterprise systems need to communicate with each other and share data, and OracleAPI is one of the important tools to help achieve seamless communication between systems. This article will start with the basic concepts and principles of OracleAPI, explore API integration strategies, and finally give specific code examples to help readers better understand and apply OracleAPI. 1. Basic Oracle API

Introduction to PHP interfaces and how to define them Introduction to PHP interfaces and how to define them Mar 23, 2024 am 09:00 AM

Introduction to PHP interface and how it is defined. PHP is an open source scripting language widely used in Web development. It is flexible, simple, and powerful. In PHP, an interface is a tool that defines common methods between multiple classes, achieving polymorphism and making code more flexible and reusable. This article will introduce the concept of PHP interfaces and how to define them, and provide specific code examples to demonstrate their usage. 1. PHP interface concept Interface plays an important role in object-oriented programming, defining the class application

Solution to NotImplementedError() Solution to NotImplementedError() Mar 01, 2024 pm 03:10 PM

The reason for the error is in python. The reason why NotImplementedError() is thrown in Tornado may be because an abstract method or interface is not implemented. These methods or interfaces are declared in the parent class but not implemented in the child class. Subclasses need to implement these methods or interfaces to work properly. How to solve this problem is to implement the abstract method or interface declared by the parent class in the child class. If you are using a class to inherit from another class and you see this error, you should implement all the abstract methods declared in the parent class in the child class. If you are using an interface and you see this error, you should implement all methods declared in the interface in the class that implements the interface. If you are not sure which

Application of interfaces and abstract classes in design patterns in Java Application of interfaces and abstract classes in design patterns in Java May 01, 2024 pm 06:33 PM

Interfaces and abstract classes are used in design patterns for decoupling and extensibility. Interfaces define method signatures, abstract classes provide partial implementation, and subclasses must implement unimplemented methods. In the strategy pattern, the interface is used to define the algorithm, and the abstract class or concrete class provides the implementation, allowing dynamic switching of algorithms. In the observer pattern, interfaces are used to define observer behavior, and abstract or concrete classes are used to subscribe and publish notifications. In the adapter pattern, interfaces are used to adapt existing classes. Abstract classes or concrete classes can implement compatible interfaces, allowing interaction with original code.

See all articles