æ·±å³éä½é¢æ¥è¯¢çAPI
程序员文章站
2024-01-28 16:23:40
...
æ·±å³éä½é¢æ¥è¯¢çAPIï¼å¯ä»¥éè¿æ·±å³éå·ç æ¥è¯¢å°ä½é¢åå¡æææçä¿¡æ¯ã ç¨å°DomxpathåCurl两æ¹é¢çç¥è¯ã æºç å·²æ管å°githubï¼å¦å¤è¦å 载个类ï¼myclass 项ç®å°åï¼https://github.com/skiy/dev æ¼ç¤ºï¼http://api.oupag.com/dev/api/shenzhentong.php?cardn
æ·±å³éä½é¢æ¥è¯¢çAPIï¼å¯ä»¥éè¿æ·±å³éå·ç æ¥è¯¢å°ä½é¢åå¡æææçä¿¡æ¯ã
ç¨å°DomxpathåCurl两æ¹é¢çç¥è¯ã
æºç å·²æ管å°githubï¼å¦å¤è¦å 载个类ï¼myclass
项ç®å°åï¼https://github.com/skiy/dev
æ¼ç¤ºï¼http://api.oupag.com/dev/api/shenzhentong.php?cardno=293005762
update 2014.10.20 22:53
åæ¥å¯ä»¥ç´æ¥ç¨GETæ¹å¼ï¼ä¸éè¦ç¨curlçPOSTæ¹å¼æ¥å¤çï¼è¿æ ·ååºå¿«äº~
PHP
curls("http://query.shenzhentong.com:8080/sztnet/qryCard.do", false, $post_cardno); //ç´æ¥GETæ¹å¼ $page = $data->curls("http://query.shenzhentong.com:8080/sztnet/qryCard.do?cardno={$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; } //æªæ¢æ¶é´å ä½é¢ preg_match("/æªæ¢å°([^\)]*)/", getTextContent($tr, 2), $expires); $results = array( "card_number" => (int) getTextContent($tr, 1), "card_balance" => getTextContent($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); ?>
æºç ,æ°ç» array($url, 1)1为file_get_contents,2为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; } }
上一篇: php-redis中的sort排序函数总结_PHP
下一篇: Oracle数据库视图与权限问题
推荐阅读
-
æ·±å³éä½é¢æ¥è¯¢çAPI
-
第十七章 使用API
-
零基础之Node.js搭建API服务器的详解
-
php快递查询API类-支持各种快递
-
【ASP.NET Web API教程】1.1 第一个ASP.NET Web API
-
【Web API系列教程】3.2 — 实战:处理数据(添加模型和控制器)
-
Spring调用第三方Api实例
-
【】求雅虎日本api解析(php),小弟我再做一个代购网(雅虎日本,乐天),求高手帮忙解析上他们两个的api
-
Google App Engine,Twitter API Proxy,Mixero搭建Twi2tt图解
-
python通过zabbix api获取主机