顺途2.0新接口配置及站站查询

master
赵鹏 2 years ago
parent d8a3387fa9
commit cbfbbaf937

@ -34,6 +34,11 @@ define("CTRIPURL","https://apiproxy.ctrip.com/apiproxy/soa2/19946");
//新携程接口(顺途)的订单号前缀
define("SHUNTU_ORDERUSER","HN");
//顺途2.0
define("SHUNTU_ID","285");
define("SHUNTU_KEY","RPLGQC5M4FAUROK0");
//聚合火车订票API key
define("JUHE_TRAIN_API_KEY","79f03107b921ef31310bd40a1415c1cb");

@ -697,7 +697,7 @@ class innerTrainSearch extends CI_Controller{
//生成请求链接
$TimeStamp = date("Y-m-d H:i:s");
$serviceName = "train.searchTrainsBetweenStations"; //每个接口都有自己名称
$strSign = $TimeStamp.$serviceName.COMPANYID.CTRIPKEY; //加密前的令牌
$strSign = $TimeStamp.$serviceName.SHUNTU_ID.SHUNTU_KEY; //加密前的令牌
$Sign = md5($strSign);
$url = "http://ctrip.21kv.com/train/ticket/searchTrainsBetweenStations"; //顺途2.0的接口每个都不一样了
@ -706,7 +706,7 @@ class innerTrainSearch extends CI_Controller{
$post_data->authentication = new stdClass();
$post_data->authentication->timeStamp = $TimeStamp;
$post_data->authentication->serviceName = $serviceName;
$post_data->authentication->companyId = COMPANYID;
$post_data->authentication->companyId = SHUNTU_ID;
$post_data->authentication->messageIdentity = $Sign;
$post_data->searchTrainsParam = new stdClass();
$post_data->searchTrainsParam->departDate = $date;
@ -721,20 +721,21 @@ class innerTrainSearch extends CI_Controller{
// //获取数据
// echo ($url . "<hr/>");
// echo(json_encode($post_data) . "<hr/>");
// die();
$ResponseJson = GetPost_http($url,json_encode($post_data),'json');
$api_end_time = microtime(true);
$ResponseData = json_decode($ResponseJson);
// echo($ResponseJson);
echo($ResponseJson);
$api_responsive_time = $api_end_time - $api_start_time;
if(empty($ResponseData->trainList)){
log_message('error','ctrip_trian|status:trains is empty |相应时间:'.$api_responsive_time);
}else{
log_message('error','ctrip_trian|status:'.$ResponseData->ResponseStatus->Ack.'|相应时间:'.$api_responsive_time);
log_message('error','ctrip_trian|status:'.$ResponseData->returnMessage.'|相应时间:'.$api_responsive_time);
}
//定义返回的json
@ -753,8 +754,8 @@ class innerTrainSearch extends CI_Controller{
//数据解析
if(!empty($ResponseData->trainList)){
foreach ($ResponseData->trainList as $TrainInfo){
$obj[$TrainInfo->fromTelCode] = $TrainInfo->fromStationName;
$obj[$TrainInfo->toTelCode] = $TrainInfo->toStationName;
$obj[$TrainInfo->fromTelcode] = $TrainInfo->fromStationName;
$obj[$TrainInfo->toTelcode] = $TrainInfo->toStationName;
$SeaType = '';
//余数初始化为空
$gjrwNum = $rwNum = $rzNum = $tdzNum = $wzNum = $yzNum = $edzNum = $ydzNum = $swzNum = $ywNum = $dwNum = $ydwNum = $edzNum = null;
@ -859,7 +860,7 @@ class innerTrainSearch extends CI_Controller{
$runMin = $TrainInfo->durationMinutes % 60;
$runHour = ($TrainInfo->durationMinutes - $runMin) / 60;
$ReturnData->data->result[$i] = '|预定|'.$TrainInfo->train12306No.'|'.$TrainInfo->trainNo.'|'.$TrainInfo->fromStationName.'|'.$TrainInfo->toStationName.'|'.$TrainInfo->fromTelCode.'|'.$TrainInfo->toTelCode.'|'.$TrainInfo->startTime.'|'.$TrainInfo->arriveTime.'|'.$runHour.':'.$runMin.'|'.$TrainInfo->canWebBuy.'||'.date('Ymd',strtotime($date)).'||||||||'.$gjrwNum.'||'.$rwNum.'|'.$rzNum.'|'.$tdzNum.'|'.$wzNum.'||'.$ywNum.'|'.$yzNum.'|'.$edzNum.'|'.$ydzNum.'|'.$swzNum.'|'.$dwNum.'|||'.$ydwNum.'|'.$erwNum;
$ReturnData->data->result[$i] = '|预定|'.$TrainInfo->train12306No.'|'.$TrainInfo->trainNo.'|'.$TrainInfo->fromStationName.'|'.$TrainInfo->toStationName.'|'.$TrainInfo->fromTelcode.'|'.$TrainInfo->toTelcode.'|'.$TrainInfo->startTime.'|'.$TrainInfo->arriveTime.'|'.$runHour.':'.$runMin.'|'.$TrainInfo->canWebBuy.'||'.date('Ymd',strtotime($date)).'||||||||'.$gjrwNum.'||'.$rwNum.'|'.$rzNum.'|'.$tdzNum.'|'.$wzNum.'||'.$ywNum.'|'.$yzNum.'|'.$edzNum.'|'.$ydzNum.'|'.$swzNum.'|'.$dwNum.'|||'.$ydwNum.'|'.$erwNum;
$data = '{"validateMessagesShowId":"_validatorMessage","status":true,"httpstatus":200,"data":{'.$PriceStr.'},"messages":[],"validateMessages":{}}';
$ReturnData->data->price[$i] = $data;

Loading…
Cancel
Save