站長(zhǎng)資訊網(wǎng)
        最全最豐富的資訊網(wǎng)站

        php怎么識(shí)別火車票

        php識(shí)別火車票的方法:1、開通火車票識(shí)別API接口;2、創(chuàng)建一個(gè)PHP示例文件;3、設(shè)置“header('Content-type:text/html;charset=utf-8');”;4、配置申請(qǐng)的appkey;5、應(yīng)用appkey;6、請(qǐng)求URL;7、獲取接口數(shù)據(jù)并分析處理即可。

        php怎么識(shí)別火車票

        php入門到就業(yè)線上直播課:進(jìn)入學(xué)習(xí)
        Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調(diào)試工具:點(diǎn)擊使用

        本教程操作環(huán)境:windows7系統(tǒng)、PHP8.1版、Dell G3電腦。

        php怎么識(shí)別火車票?

        1、開通火車票識(shí)別API接口:

        通過https://www.juhe.cn/docs/api/id/522?s=cpphpcn注冊(cè)及開通

        接口說明:

        • 該接口支持火車票全字段的識(shí)別,包括編號(hào)、票價(jià)、姓名、座位號(hào)、出發(fā)時(shí)間、出發(fā)站、到達(dá)站、車次、席別等。

        • 返回格式:json

        • 請(qǐng)求方式:post

        • 請(qǐng)求示例:http://v.juhe.cn/trainTicketOcr/index.php

        2、基于php的12306火車票查詢接口調(diào)用代碼實(shí)例

        php代碼示例如下:

        1.[代碼][PHP]代碼  // +-------------------  header('Content-type:text/html;charset=utf-8');  //配置您申請(qǐng)的appkey  $appkey = "*********************";  //************1.站到站查詢(含票價(jià))************  $url = "http://apis.juhe.cn/train/s2swithprice";  $params = array(  "start" => "",//出發(fā)站  "end" => "",//終點(diǎn)站  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  "dtype" => "",//返回?cái)?shù)據(jù)的格式,xml或json,默認(rèn)json  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  //************2.12306訂票②:車次票價(jià)查詢************  $url = "http://apis.juhe.cn/train/ticket.price.php";  $params = array(  "train_no" => "",//列次編號(hào),對(duì)應(yīng)12306訂票①:查詢車次中返回的train_no  "from_station_no" => "",//出發(fā)站序號(hào),對(duì)應(yīng)12306訂票①:查詢車次中返回的from_station_no  "to_station_no" => "",//出發(fā)站序號(hào),對(duì)應(yīng)12306訂票①:查詢車次中返回的to_station_no  "date" => "",//默認(rèn)當(dāng)天,格式:2014-12-25  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  //************3.車次查詢************  $url = "http://apis.juhe.cn/train/s";  $params = array(  "name" => "",//車次名稱,如:G4  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  "dtype" => "",//返回?cái)?shù)據(jù)的格式,xml或json,默認(rèn)json  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  //************4.站到站查詢************  $url = "http://apis.juhe.cn/train/s2s";  $params = array(  "start" => "",//出發(fā)站  "end" => "",//終點(diǎn)站  "traintype" => "",//列車類型,G-高速動(dòng)車 K-快速 T-空調(diào)特快 D-動(dòng)車組 Z-直達(dá)特快 Q-其他  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  "dtype" => "",//返回?cái)?shù)據(jù)的格式,xml或json,默認(rèn)json  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  //************5.12306實(shí)時(shí)余票查詢************  $url = "http://apis.juhe.cn/train/yp";  $params = array(  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  "dtype" => "",//返回?cái)?shù)據(jù)的格式,xml或json,默認(rèn)json  "from" => "",//出發(fā)站,如:上海虹橋  "to" => "",// 到達(dá)站,如:溫州南  "date" => "",//出發(fā)日期,默認(rèn)今日  "tt" => "",//車次類型,默認(rèn)全部,如:G(高鐵)、D(動(dòng)車)、T(特快)、Z(直達(dá))、K(快速)、Q(其他)  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  //************6.12306訂票①:查詢車次************  $url = "http://apis.juhe.cn/train/ticket.cc.php";  $params = array(  "from" => "",//出發(fā)站名稱:如上海虹橋  "to" => "",//到達(dá)站名稱:如溫州南  "date" => "",//默認(rèn)當(dāng)天,格式:2014-07-11  "tt" => "",//車次類型,默認(rèn)全部,如:G(高鐵)、D(動(dòng)車)、T(特快)、Z(直達(dá))、K(快速)、Q(其他)  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  //************7.火車票代售點(diǎn)查詢************  $url = "http://apis.juhe.cn/train/dsd";  $params = array(  "province" => "",//省份,如:浙江  "city" => "",//城市,如:溫州  "county" => "",//區(qū)/縣,如:鹿城區(qū)  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  "dtype" => "",//返回?cái)?shù)據(jù)的格式,xml或json,默認(rèn)json  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  //************8.列車站點(diǎn)列表************  $url = "http://apis.juhe.cn/train/station.list.php";  $params = array(  "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁查詢)  "dtype" => "",//返回?cái)?shù)據(jù)的格式,xml或json,默認(rèn)json  );  $paramstring = http_build_query($params);  $content = juhecurl($url,$paramstring);  $result = json_decode($content,true);  if($result){  if($result['error_code']=='0'){  print_r($result);  }else{  echo $result['error_code'].":".$result['reason'];  }  }else{  echo "請(qǐng)求失敗";  }  //**************************************************  /**  * 請(qǐng)求接口返回內(nèi)容  * @param string $url [請(qǐng)求的URL地址]  * @param string $params [請(qǐng)求的參數(shù)]  * @param int $ipost [是否采用POST形式]  * @return string  */  function juhecurl($url,$params=false,$ispost=0){  $httpInfo = array();  $ch = curl_init();  curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );  curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );  curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );  curl_setopt( $ch, CURLOPT_TIMEOUT , 60);  curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);  if( $ispost )  {  curl_setopt( $ch , CURLOPT_POST , true );  curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );  curl_setopt( $ch , CURLOPT_URL , $url );  }  else  {  if($params){  curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );  }else{  curl_setopt( $ch , CURLOPT_URL , $url);  }  }  $response = curl_exec( $ch );  if ($response === FALSE) {  //echo "cURL Error: " . curl_error($ch);  return false;  }  $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );  $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );  curl_close( $ch );  return $response;  }
        登錄后復(fù)制

        推薦學(xué)習(xí):《PHP視頻教程》

        贊(0)
        分享到: 更多 (0)
        網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)
        主站蜘蛛池模板: 日韩精品一区二区午夜成人版| 精品无人码麻豆乱码1区2区| 亚洲精品tv久久久久久久久| 国产精品久久久久aaaa| 伊人久久无码精品中文字幕| 99熟女精品视频一区二区三区 | 欧美精品华人在线| 久久精品天天中文字幕人妻| 午夜精品久久久久成人| 国内精品久久久久久久亚洲| 久久国产精品久久久| 久久亚洲国产成人精品性色| 亚洲高清国产拍精品青青草原| 狠狠色伊人久久精品综合网| 91探花国产综合在线精品| 青青青国产精品国产精品久久久久| 国产精品美女久久久久久2018| 亚洲AV永久无码精品| 青草国产精品视频。| 久久精品国产欧美日韩| 国产亚洲精品影视在线产品| 99精品伊人久久久大香线蕉| 中文字幕成人精品久久不卡| 欧美精品手机在线播放| 女人香蕉久久**毛片精品| 国产乱码精品一区二区三区四川人| 国产精品视频一区二区噜噜| 久久久久久国产精品无码超碰| 无码人妻精品一区二区三区东京热| 亚洲国产精品无码久久青草| 亚洲精品国产自在久久 | 99精品国产一区二区三区| 精品无码国产一区二区三区51安| 久久夜色精品国产欧美乱| 日韩精品久久无码人妻中文字幕| 亚洲AV无码成人精品区蜜桃| 无码精品黑人一区二区三区| 少妇人妻偷人精品无码视频| 久久亚洲精品中文字幕| 99精品一区二区三区无码吞精| 国产成人精品综合网站|