Php provides more than 12306 ticket queries and price query examples. Copy the code as follows :? Php *** ticket interface class ** @ authorchepiao100 ** classchepiao100 {*** interface address * @ varstring * private $ _ apiurlwww. chepiao100.c
The code is as follows:
/**
* Ticket interface
*
* @ Author chepiao100
*
*/
Class chepiao100
{
/**
* Interface address
* @ Var string
*/
Private $ _ apiurl = 'http: // www.chepiao100.com/api /';
/**
* Return interface data
*
* @ Param string $ method interface method
* @ Param array $ param request parameters
* @ Return mixed
*/
Function getData ($ method, $ param)
{
$ Post = http_build_query ($ param );
$ Html = $ this-> fetch_html ($ this-> _ apiurl. $ method, $ post );
$ JsonArr = json_decode ($ html, TRUE );
If ($ jsonArr ['errmsg '] = 'y '){
Return $ jsonArr ['data'];
} Else {
Return $ jsonArr ['errmsg '];
}
}
/**
* Request HTTP
*
* @ Param string $ url
* @ Param string $ post
* @ Return mixed
*/
Function fetch_html ($ url, $ post)
{
$ Ch = curl_init ($ url );
Curl_setopt ($ ch, CURLOPT_TIMEOUT, 60 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
Curl_setopt ($ ch, CURLOPT_POST, true );
// Curl_setopt ($ ch, CURLOPT_PROXY, 'http: // 10.100.10.100: 100 ');
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post );
$ Html = curl_exec ($ ch );
Curl_close ($ ch );
Return $ html;
}
}
/** End class of chepiao100 **/
The http://www.bkjia.com/PHPjc/755843.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/755843.htmlTechArticle code is as follows :? Php/*** ticket interface class ** @ author chepiao100 **/class chepiao100 {/*** interface address * @ var string */private $ _ apiurl = 'http: // www. chepiao100.c...