Shenzhen Tong balance query API

Source: Internet
Author: User
You can use the Shenzhen phone number to query the balance, card validity period, and other information. Knowledge of Domxpath and Curl is used. The source code has been hosted on github. In addition, you need to load a class: myclass Project address: github. comskiydev Demo: api. oupag. comdevapishenzhentong. php? Cardn

You can use the Shenzhen phone number to query the balance, card validity period, and other information. Knowledge of Domxpath and Curl is used. The source code has been hosted on github, and also to load a class: myclass Project address: https://github.com/skiy/dev Demo: http://api.oupag.com/dev/api/shenzhentong.php? Cardn

You can use the Shenzhen phone number to query the balance, card validity period, and other information.
Knowledge of Domxpath and Curl is used.
The source code has been hosted on github. In addition, you need to load a class: myclass
Project address: https://github.com/skiy/dev

Demo: http://api.oupag.com/dev/api/shenzhentong.php? Cardno= 293005762

Update
It turns out that the GET method can be used directly without the curl POST method, so the response is faster ~
PHP
 Curls ("http://query.shenzhentong.com: 8080/sztnet/qryCard. do ", false, $ post_cardno); // GET method $ page = $ data-> curls (" http://query.shenzhentong.com: 8080/sztnet/qryCard. do? Cardno = {$ cardno} "); $ page = $ data-> pageToDom ($ page," GBK "); $ tr = $ page-> query ("// table [@ class = 'tableac']/tr/td"); function getTextContent ($ m_query, $ m_id) {$ myTXT = str_replace (":", "", $ m_query-> item ($ m_id)-> textContent); return $ myTXT ;} // The balance preg_match ("/until ([^ \)] *)/", getTextContent ($ tr, 2), $ expires) within the deadline ); $ results = array ("card_number" => (int) getTextContent ($ tr, 1), "card_balance" => ge TTextContent ($ tr, 3), "balance_time" => $ expires [1], "card_validity" => getTextContent ($ tr, 5 ), "current_time" => date ("Y-m-d H: I: s", time (); echo json_encode ($ results);?>
 Source code, array ($ url, 1) 1 is file_get_contents, 2 is curl */public function pageToDom ($ data, $ encoded = "UTF-8 ") {if (is_array ($ data) {if ($ data [1] = 1) {$ datas = @ file_get_contents ($ data [0]);} if ($ data [1] = 2) {$ datas =@$ this-> curls ($ data [0]) ;}} else {$ datas = $ data ;} if (empty ($ datas) {return false;} $ meta ='
 '; $ Datas = $ meta. $ datas; $ xmldoc = new DOMDocument (); @ $ xmldoc-> loadHTML ($ datas); $ xmldoc-> normalizeDocument (); $ domresult = new Domxpath ($ xmldoc ); return $ domresult ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.