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

        php怎么識別火車票

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

        php怎么識別火車票

        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怎么識別火車票?

        1、開通火車票識別API接口:

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

        接口說明:

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

        • 返回格式:json

        • 請求方式:post

        • 請求示例:http://v.juhe.cn/trainTicketOcr/index.php

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

        php代碼示例如下:

        1.[代碼][PHP]代碼  // +-------------------  header('Content-type:text/html;charset=utf-8');  //配置您申請的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 "請求失敗";  }  //**************************************************  //************2.12306訂票②:車次票價(jià)查詢************  $url = "http://apis.juhe.cn/train/ticket.price.php";  $params = array(  "train_no" => "",//列次編號,對應(yīng)12306訂票①:查詢車次中返回的train_no  "from_station_no" => "",//出發(fā)站序號,對應(yīng)12306訂票①:查詢車次中返回的from_station_no  "to_station_no" => "",//出發(fā)站序號,對應(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 "請求失敗";  }  //**************************************************  //************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 "請求失敗";  }  //**************************************************  //************4.站到站查詢************  $url = "http://apis.juhe.cn/train/s2s";  $params = array(  "start" => "",//出發(fā)站  "end" => "",//終點(diǎn)站  "traintype" => "",//列車類型,G-高速動車 K-快速 T-空調(diào)特快 D-動車組 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 "請求失敗";  }  //**************************************************  //************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(動車)、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 "請求失敗";  }  //**************************************************  //************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(動車)、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 "請求失敗";  }  //**************************************************  //************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 "請求失敗";  }  //**************************************************  //************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 "請求失敗";  }  //**************************************************  /**  * 請求接口返回內(nèi)容  * @param string $url [請求的URL地址]  * @param string $params [請求的參數(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號-2    滬公網(wǎng)安備31011702889846號
        主站蜘蛛池模板: 欧洲成人午夜精品无码区久久 | 国产精品亚洲欧美大片在线观看| 亚洲欧美国产精品专区久久| 欧美+亚洲+精品+三区| 精品亚洲成AV人在线观看| 人人妻人人澡人人爽精品欧美 | 久草热8精品视频在线观看| 久久精品国产亚洲麻豆| 国产精品久久午夜夜伦鲁鲁| 亚洲国产精品无码久久久不卡| 蜜臀AV无码国产精品色午夜麻豆| 国产精品亚洲一区二区在线观看| 2024国产精品极品色在线| 国产精品一在线观看| 91精品国产91久久综合| 国自产偷精品不卡在线| 欧美日韩人妻精品一区二区在线| 亚洲欧洲美洲无码精品VA| 日韩精品一区二区三区中文字幕 | 国产国产成人久久精品| 中文字幕亚洲精品资源网| 欧美777精品久久久久网| 欧美极品欧美精品欧美视频| 午夜精品视频在线观看| 97精品国产自在现线免费观看| 91精品国产91久久| 国产成人综合精品一区| 国产午夜精品理论片久久| 国内精品久久久久久久涩爱| 精品国产乱码久久久久久浪潮 | 99热这里只有精品在线| 国产精品久久国产精品99盘| 精品国产第1页| mm1313亚洲国产精品无码试看| 国产高清精品在线| 国产精品极品| 精品国产污污免费网站入口在线| 精品国产一区二区三区久久蜜臀 | 一本一道久久精品综合| 国产精品被窝福利一区| 久久久人妻精品无码一区|