More than 12,306 votes query, the price query function realization, this article will make the related introduction.
<?php/** * Ticket Interface class * * @author chepiao100 * */class chepiao100{/** * Interface Address * @var String */private $_apiurl = ' https: www.chepiao100.com/api/'; /** * Returns interface data * * @param string $method interface method * @param array $param request parameter * @return Mixed */function GetData ($me Thod, $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, ' 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 introduced more than 12,306 votes query, price query function, and the use of code to achieve the relevant functions, more relevant content please pay attention to the PHP Chinese network.
Related recommendations:
Introduction to PHP quick Export table data related tutorials
How to use the arrayaccess of PHP pre-defined interface
Specification for naming of PHP files, naming of classes and methods, naming of variables, etc.