|
|
|
@ -2,9 +2,9 @@
|
|
|
|
|
if (!defined('BASEPATH'))
|
|
|
|
|
exit('No direct script access allowed');
|
|
|
|
|
//途牛apiurl
|
|
|
|
|
define("TUNIU_URL","218.94.82.118:13532");
|
|
|
|
|
define("TUNIU_URL","https://open.tuniu.cn");
|
|
|
|
|
//途牛apikey
|
|
|
|
|
define("TUNIU_KEY","Te56CBQmorzJGeYIIK");
|
|
|
|
|
define("TUNIU_KEY","AILvoDj8El7KCSMe25");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,9 +22,9 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
|
//创建请求签名
|
|
|
|
|
public function create_sign(){
|
|
|
|
|
$time = date('Y-m-d H:i:s',time());
|
|
|
|
|
$secretKey = 'qvHMJVywEQqsd4EneHQl';
|
|
|
|
|
$secretKey = 'hxRkFRKaYCScaJRRO2db';
|
|
|
|
|
$id = 'retailId25';
|
|
|
|
|
$str = 'planDateStrhaina';
|
|
|
|
|
$str = 'retailName海纳国旅';
|
|
|
|
|
$timeStamp = 'timestamp'.$time;
|
|
|
|
|
$sign = $secretKey.$id.'apiKey'.TUNIU_KEY.$str.$timeStamp.$secretKey;
|
|
|
|
|
return strtoupper(md5($sign));
|
|
|
|
@ -47,17 +47,19 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
|
"data": { "trainDate": "'.$date.'", "fromStation": "'.$fromStation.'", "toStation": "'.$toStation.'", "trainCode": "" }
|
|
|
|
|
}';
|
|
|
|
|
$back_data = post_tuniu($url,$post_data,$method = 'POST');
|
|
|
|
|
//print_r($post_data);
|
|
|
|
|
//print_r(json_decode($back_data));
|
|
|
|
|
print_r(json_decode($back_data));
|
|
|
|
|
$return_data = new stdClass();
|
|
|
|
|
$return_data->returnCode = json_decode($back_data)->returnCode;
|
|
|
|
|
$return_data->httpstatus = 200;
|
|
|
|
|
$return_data->data = new stdClass();
|
|
|
|
|
$return_data->data->result = array();
|
|
|
|
|
$return_data->data->map = new stdClass();
|
|
|
|
|
$i = 0;
|
|
|
|
|
$pricestr = '';
|
|
|
|
|
if(!empty(json_decode($back_data)->data)){
|
|
|
|
|
foreach (json_decode($back_data)->data as $value){
|
|
|
|
|
$obj[$value->fromStationCode] = $value->fromStationName;
|
|
|
|
|
$obj[$value->toStationCode] = $value->toStationName;
|
|
|
|
|
$seat_type = '';
|
|
|
|
|
if(isset($value->gjrwPrice)){
|
|
|
|
|
if(is_numeric($value->gjrwPrice)){
|
|
|
|
@ -124,12 +126,14 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
|
$pricestr = $seat_type.'"train_no":'.'"'.$value->trainNo.'"';
|
|
|
|
|
//余票字符串
|
|
|
|
|
$return_data->data->result[$i] = '|预定|'.$value->trainNo.'|'.$value->trainCode.'|'.$value->fromStationName.'|'.$value->toStationName.'|'.$value->fromStationCode.'|'.$value->toStationCode.'|'.$value->startTime.'|'.$value->arriveTime.'|'.$value->runTime.'|'.$value->canBuyNow.'||'.date('Ymd',strtotime($value->trainStartDate)).'||||||||'.ticket_exchange($value->gjrwNum).'|'.ticket_exchange($value->qtxbNum).'|'.ticket_exchange($value->rwNum).'|'.ticket_exchange($value->rzNum).'|'.ticket_exchange($value->tdzNum).'|'.ticket_exchange($value->wzNum).'||'.ticket_exchange($value->ywNum).'|'.ticket_exchange($value->yzNum).'|'.ticket_exchange($value->edzNum).'|'.ticket_exchange($value->ydzNum).'|'.ticket_exchange($value->swzNum).'|'.ticket_exchange($value->dwNum).'||';
|
|
|
|
|
$i++;
|
|
|
|
|
$data = '{"validateMessagesShowId":"_validatorMessage","status":true,"httpstatus":200,"data":{'.$pricestr.'},"messages":[],"validateMessages":{}}';
|
|
|
|
|
$return_data->data->price[$i] = $data;
|
|
|
|
|
$this->tuniuprice_model->addOrUpdate($value->trainNo,$value->trainCode,$value->fromStationCode,$value->toStationCode,json_encode($data));
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
print_r(json_encode($return_data));
|
|
|
|
|
$return_data->data->map = (object)$obj;
|
|
|
|
|
print_r($return_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取价格
|
|
|
|
|