<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');
//途牛apiurl
define("TUNIU_FLIGHT_API","http://silkroad.tuniu.com/atd/dist/api");
//id
define("TUNIU_FLIGHT_ID","23770");
//途牛apikey
define("TUNIU_FLIGHT_KEY","MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEAq2ueljB82bcpF228w5mpCVs+ZK8kE7TQuw2LDegNRUJyP8PlVJXpB438bkTq6J/riqMNLaztUVVXFTL8YXeh7QIDAQABAkEAp9GUUDToBbzq3aTxSA0HD8HkM23DRAeg0X9QwyyK0WHBe/zXgvJ4t6SArTSWUOV3esxGbZQUSOB3U7m89rR0AQIhANUsDojh5WCkNo8Oaqfv35DE9JD5JvixoGMnrNCnozZJAiEAzdwsiYUp2Mlem6bizVsVGejHYMdAG1LCnSbpkUtQ/oUCIGuwuhcEp7BOxRE4I0F7uOGV3kdu1vVEJtZwsKkoRxehAiEAkAYZVsFGjLgdq7JvfRLbSXw1eX0NWdBl/gLKaG+UI+0CIQDFvEQz3ueuyfj/4DnPUnfo0QnAiKJ5Mv57adjoeAOIpg==");



class Tuniu_flight extends CI_Controller{
	
	public function __construct(){
        // header("Content-Type: text/html;charset=utf-8");
        parent::__construct();
		$this->load->helper('tuniu');
    }
	
	public function index(){
		echo 'tuniu flight';
	}
	
	public function data_show(){
		$timestamp = time();
		$function = 'queryNew';
		$data = '{"channelId":7,"departureDate":"2019-07-10","dstCityCode":"PVG","orgCityCode":"PEK","vendorId":[4333]}';
		$sign = md5(TUNIU_FLIGHT_KEY.$data.$timestamp);
		
		$postJson = '{
			"purchaseId": '.TUNIU_FLIGHT_ID.',
			"sign": "'.$sign .'",
			"timestamp": '.$timestamp.',
			"function": "'.$function.'",
			"data":'.$data.'
		}';
		
		$returnJson = post_tuniu(TUNIU_FLIGHT_API,$postJson,'POST');
		
		$returnData = json_decode($returnJson);
		//print_r($returnData);
		echo $returnJson;
	}
}   