|
|
@ -35,8 +35,11 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取余票
|
|
|
|
//获取余票
|
|
|
|
public function search($date,$fromStation,$toStation){
|
|
|
|
public function search($date=null,$fromStation=null,$toStation=null){
|
|
|
|
$sign = $this->create_sign();
|
|
|
|
if(!$date || !$fromStation || !$toStation){
|
|
|
|
|
|
|
|
exit('传参错误!');
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$sign = $this->create_sign();
|
|
|
|
$url = TUNIU_URL.'/train/search';
|
|
|
|
$url = TUNIU_URL.'/train/search';
|
|
|
|
$time = date('Y-m-d H:i:s',time());
|
|
|
|
$time = date('Y-m-d H:i:s',time());
|
|
|
|
$post_data = '{
|
|
|
|
$post_data = '{
|
|
|
@ -135,6 +138,7 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$return_data->data->map = (object)$obj;
|
|
|
|
$return_data->data->map = (object)$obj;
|
|
|
|
print_r(json_encode($return_data));
|
|
|
|
print_r(json_encode($return_data));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取价格
|
|
|
|
//获取价格
|
|
|
@ -143,9 +147,13 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
toStationCode:终点站三字码
|
|
|
|
toStationCode:终点站三字码
|
|
|
|
trainCode:车次
|
|
|
|
trainCode:车次
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function get_price($fromStationCode,$toStationCode,$trainCode){
|
|
|
|
public function get_price($fromStationCode=null,$toStationCode=null,$trainCode=null){
|
|
|
|
$return_data = $this->tuniuprice_model->get_price($fromStationCode,$toStationCode,$trainCode);
|
|
|
|
if(!$fromStationCode || !$toStationCode || !$trainCode){
|
|
|
|
print_r(json_decode($return_data->TPL_Price));
|
|
|
|
exit('传参错误!');
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
$return_data = $this->tuniuprice_model->get_price($fromStationCode,$toStationCode,$trainCode);
|
|
|
|
|
|
|
|
print_r(json_decode($return_data->TPL_Price));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//占座下单
|
|
|
|
//占座下单
|
|
|
@ -282,6 +290,21 @@ class Tuniu_train extends CI_Controller{
|
|
|
|
print_r($back_data);
|
|
|
|
print_r($back_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//车站三字码查询
|
|
|
|
|
|
|
|
public function telecodeQuery(){
|
|
|
|
|
|
|
|
$sign = $this->create_sign();
|
|
|
|
|
|
|
|
$url = TUNIU_URL.'/train/telecodeQuery';
|
|
|
|
|
|
|
|
$time = date('Y-m-d H:i:s',time());
|
|
|
|
|
|
|
|
$post_data = '{
|
|
|
|
|
|
|
|
"apiKey": "'.TUNIU_KEY.'",
|
|
|
|
|
|
|
|
"sign": "'.$sign.'",
|
|
|
|
|
|
|
|
"timestamp": "'.$time.'",
|
|
|
|
|
|
|
|
"data": null
|
|
|
|
|
|
|
|
}';
|
|
|
|
|
|
|
|
$back_data = post_tuniu($url,$post_data,$method = 'POST');
|
|
|
|
|
|
|
|
print_r($back_data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//身份验证
|
|
|
|
//身份验证
|
|
|
|
public function validate(){
|
|
|
|
public function validate(){
|
|
|
|
//$name = $this->input->post('name');
|
|
|
|
//$name = $this->input->post('name');
|
|
|
|