Shenzhen Tong Balance query API, through the Shenzhen pass number to check the balance and card validity and other information.
This is my busy today to do nothing, because a few days ago, Shenzhen no money did not remember to recharge, when there is no change, make me very depressed ... Say less nonsense, directly on the code.
Use both Domxpath and curl knowledge.
The source is already hosted on GitHub, and a different class is loaded: MyClass
Project Address: Https://github.com/skiy/dev
<?php/** * shenzhentong.php * Shenzhen Tong API * @autuor: Skiychan * @contact: [email protected] & qq:1005043848 * @web Site:www.zzzzy.com & Http://weibo.com/ckiy * @date: 2014-10-19 * @readme https://github.com/skiy/dev/blob/master/ Docs/shenzhentong.md *//** Link: http://query.shenzhentong.com:8080/sztnet/qrycard.jsp interface information url:http:// Query.shenzhentong.com:8080/sztnet/qrycard.dopost method: cardno:328375558### return field JSON format return Value field | Field type | Field Description----|------|----Card_number | int | Card number Card_balance | string | Isla Canela Balance Balance_time | string | Balance cut-off time card_validity | string | Card Validity Current_time | string | Query time */require_once ". /libs/myclass.php "; Date_default_timezone_set ("Asia/shanghai"); $cardno = Isset ($_get["Cardno"])? $_get["Cardno"]: 0; $post _cardno = "cardno={$cardno}"; $data = new Myclass (); $page = $data->curls ("Http://query.shenzhentong.com:8080/sztnet/qryCard.do", False, $post _cardno); $page = $data->pagetodom ($page, "GBK"); $TR = $page->query ("//table[@class = ' tableact ']/tr/td "); function Gettextcontent ($m _query, $m _id) {$myTXT = Str_replace (":", "", $m _query->item ($m _id)->textcontent); return $myTXT; }//Deadline balance Preg_match ("/Cutoff to ([^\)]*)/", Gettextcontent ($TR, 2), $expires); $results = Array ("Card_number" = (int) gettextcontent ($TR, 1), "card_balance" = Gettextcontent ($t R, 3), "balance_time" = $expires [1], "card_validity" = Gettextcontent ($tr, 5), "Current_time "= = Date (" Y-m-d h:i:s ", Time ())); echo Json_encode ($results);? >
Shenzhen Pass Balance query API