欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php如何識別火車票

這篇文章主要介紹“php如何識別火車票”,在日常操作中,相信很多人在php如何識別火車票問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”php如何識別火車票”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

創(chuàng)新互聯(lián)建站長期為上1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為彭山企業(yè)提供專業(yè)的網(wǎng)站設(shè)計(jì)、網(wǎng)站制作彭山網(wǎng)站改版等技術(shù)服務(wù)。擁有10余年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。

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

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

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

接口說明:

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

  • 返回格式:json

  • 請求方式:post

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;

}

到此,關(guān)于“php如何識別火車票”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

網(wǎng)站標(biāo)題:php如何識別火車票
網(wǎng)頁URL:http://www.chinadenli.net/article10/igpjdo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營銷外貿(mào)建站靜態(tài)網(wǎng)站網(wǎng)站收錄網(wǎng)站設(shè)計(jì)網(wǎng)頁設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司