æ·±å³éä½é¢æ¥è¯¢çAPI
程序员文章站
2022-06-11 15:33:15
...
æ·±å³éä½é¢æ¥è¯¢ç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; } }
推荐阅读
-
用HTML5 Canvas API中的clearRect()方法实现橡皮擦功能
-
HTML5 Canvas API中drawImage()方法的使用实例
-
使用HTML5 Canvas API中的clip()方法裁剪区域图像
-
HTML5的Geolocation地理位置定位API使用教程
-
api对接和sdk对接区别(全网最详解读两者区别)
-
图片上传插件ImgUploadJS:用HTML5 File API 实现截图粘贴上传、拖拽上传
-
HTML5 History API 实现无刷新跳转
-
详解HTML5中的Communication API基本使用方法
-
PhpDocumentor 2安装以及生成API文档的方法
-
前后端分离后台api接口框架探索