Home>Article>Backend Development> PHP code implements 12306 remaining ticket query and price query functions
12306 The implementation of the remaining ticket query and price query functions will be introduced in this article.
fetch_html($this->_apiurl.$method, $post); $jsonArr = json_decode($html, TRUE); if ( $jsonArr['errMsg'] == 'Y') { return $jsonArr['data']; } else { return $jsonArr['errMsg']; } } /** * 请求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, 'https://10.100.10.100:3128'); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $html = curl_exec($ch); curl_close($ch); return $html; } } /** End class of chepiao100 **/
This article introduces the 12306 remaining ticket query and price query functions, and uses code to implement related functions. For more related content, please pay attention to the PHP Chinese website.
Related recommendations:
Introduction to PHP related tutorials for quickly exporting Table data
Explain the use of ArrayAccess, the PHP predefined interface Method
Introduces PHP file naming, class and method naming, variable naming and other specifications
The above is the detailed content of PHP code implements 12306 remaining ticket query and price query functions. For more information, please follow other related articles on the PHP Chinese website!