亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網
    最全最豐富的資訊網站

    php怎么識別火車票

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

    php怎么識別火車票

    php入門到就業(yè)線上直播課:進入學習
    Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調試工具:點擊使用

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

    php怎么識別火車票?

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

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

    接口說明:

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

    • 返回格式:json

    • 請求方式:post

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

    2、基于php的12306火車票查詢接口調用代碼實例

    php代碼示例如下:

    1.[代碼][PHP]代碼  // +-------------------  header('Content-type:text/html;charset=utf-8');  //配置您申請的appkey  $appkey = "*********************";  //************1.站到站查詢(含票價)************  $url = "http://apis.juhe.cn/train/s2swithprice";  $params = array(  "start" => "",//出發(fā)站  "end" => "",//終點站  "key" => $appkey,//應用APPKEY(應用詳細頁查詢)  "dtype" => "",//返回數據的格式,xml或json,默認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訂票②:車次票價查詢************  $url = "http://apis.juhe.cn/train/ticket.price.php";  $params = array(  "train_no" => "",//列次編號,對應12306訂票①:查詢車次中返回的train_no  "from_station_no" => "",//出發(fā)站序號,對應12306訂票①:查詢車次中返回的from_station_no  "to_station_no" => "",//出發(fā)站序號,對應12306訂票①:查詢車次中返回的to_station_no  "date" => "",//默認當天,格式:2014-12-25  "key" => $appkey,//應用APPKEY(應用詳細頁查詢)  );  $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,//應用APPKEY(應用詳細頁查詢)  "dtype" => "",//返回數據的格式,xml或json,默認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" => "",//終點站  "traintype" => "",//列車類型,G-高速動車 K-快速 T-空調特快 D-動車組 Z-直達特快 Q-其他  "key" => $appkey,//應用APPKEY(應用詳細頁查詢)  "dtype" => "",//返回數據的格式,xml或json,默認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實時余票查詢************  $url = "http://apis.juhe.cn/train/yp";  $params = array(  "key" => $appkey,//應用APPKEY(應用詳細頁查詢)  "dtype" => "",//返回數據的格式,xml或json,默認json  "from" => "",//出發(fā)站,如:上海虹橋  "to" => "",// 到達站,如:溫州南  "date" => "",//出發(fā)日期,默認今日  "tt" => "",//車次類型,默認全部,如:G(高鐵)、D(動車)、T(特快)、Z(直達)、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" => "",//到達站名稱:如溫州南  "date" => "",//默認當天,格式:2014-07-11  "tt" => "",//車次類型,默認全部,如:G(高鐵)、D(動車)、T(特快)、Z(直達)、K(快速)、Q(其他)  "key" => $appkey,//應用APPKEY(應用詳細頁查詢)  );  $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.火車票代售點查詢************  $url = "http://apis.juhe.cn/train/dsd";  $params = array(  "province" => "",//省份,如:浙江  "city" => "",//城市,如:溫州  "county" => "",//區(qū)/縣,如:鹿城區(qū)  "key" => $appkey,//應用APPKEY(應用詳細頁查詢)  "dtype" => "",//返回數據的格式,xml或json,默認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.列車站點列表************  $url = "http://apis.juhe.cn/train/station.list.php";  $params = array(  "key" => $appkey,//應用APPKEY(應用詳細頁查詢)  "dtype" => "",//返回數據的格式,xml或json,默認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 "請求失敗";  }  //**************************************************  /**  * 請求接口返回內容  * @param string $url [請求的URL地址]  * @param string $params [請求的參數]  * @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;  }
    登錄后復制

    推薦學習:《PHP視頻教程》

    贊(0)
    分享到: 更多 (0)
    網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號