Example #1
0
 public function search_airline($post_data)
 {
     if (!$post_data) {
         return false;
     }
     $data = postCurl(AIRLINE_API, $post_data);
     if (!$data) {
         return false;
     }
     return $data;
 }
Example #2
0
 public function query_xzapi($data = array())
 {
     $return = array();
     if (!$data) {
         return false;
     }
     $result = postCurl(BUS_API_XZ, $data);
     $ret = ex_json_decode($result, 1);
     if (!$ret) {
         return false;
     }
     foreach ($ret as $val) {
         $return['data'][] = array('departDate' => date('Y-m-d', strtotime($data['sdate'])), 'busCode' => trim($val['attributes']['bus_code']), 'departTime' => date('H:i', strtotime($val['attributes']['plan_time'])), 'departStation' => trim($val['attributes']['sst_name']['0']), 'arriveStation' => trim($val['attributes']['dst_name']['0']), 'terminalStation' => trim($val['attributes']['tst_name']['0']), 'takeTime' => trim($val['attributes']['driving_time']), 'seats' => trim($val['attributes']['max_tickets']), 'busLevel' => trim($val['attributes']['m_name']['0']), 'remainTickets' => trim(html_entity_decode($val['attributes']['available_tickets'])), 'startStation' => trim($val['attributes']['sst_name']['0']), 'fullPrice' => trim($val['attributes']['full_price']), 'halfPrice' => '', 'verifyMessage' => '', 'mileages' => trim($val['attributes']['mileage']), 'arriveTime' => date('H:i', strtotime($val['attributes']['plan_time']) + $val['attributes']['driving_time'] * 3600));
     }
     return $return;
 }
Example #3
0
 public function show()
 {
     $postdata = $this->get_query_parameters();
     $buffer_key = md5(serialize($postdata));
     $output = $this->buffer->select($buffer_key);
     $output = $output ? json_decode($output, 1) : array();
     if (!$output) {
         $json_data = postCurl(AIRLINE_API, $postdata);
         $result = json_decode($json_data, 1);
         if ($result['Message']) {
             $this->errorOutput($result['Message']);
         }
         $output = array();
         $output['total'] = count($result['Data']);
         $output['data'] = $result['Data'] ? $result['Data'] : array();
         if ($output['total']) {
             foreach ($result['Data'] as $key => $val) {
                 $output['data'][$key]['EstimateArriveTime'] = date('H:i', strtotime($val['EstimateArriveTime']));
                 $output['data'][$key]['EstimateDeparTime'] = date('H:i', strtotime($val['EstimateDeparTime']));
                 switch ($output['data'][$key]['StatusRemark']) {
                     case '到达':
                         $statu_color = '14A0C8';
                         break;
                     case '起飞':
                         $statu_color = '6DCA7E';
                         break;
                     case '计划':
                         $statu_color = '7582B5';
                         break;
                     case '延误':
                         $statu_color = 'E1453C';
                         break;
                     case '取消':
                         $statu_color = 'ABABAB';
                         break;
                     default:
                         $statu_color = '14a0c8';
                 }
                 $output['data'][$key]['StatusRemarkColor'] = $statu_color;
             }
         }
         $this->buffer->replace($buffer_key, json_encode($output));
     }
     $this->addItem($output);
     $this->output();
 }
Example #4
0
 public function query($data = array())
 {
     if (!$data) {
         return false;
     }
     $ret = postCurl(TRAIN_API, $data);
     if (!$ret) {
         return false;
     }
     //如果需要缓存数据,就缓存数据
     if (IS_CACHE_TRAIN) {
         $filePath = TRAIN_DATA_CACHE;
         if (hg_mkdir(TRAIN_DATA_CACHE) && is_writeable(TRAIN_DATA_CACHE)) {
             file_put_contents(TRAIN_DATA_CACHE . $data['DepartCity'] . '#' . $data['ArriveCity'] . '#' . $data['DepartDate'] . '.txt', $ret);
         }
     }
     return $ret;
 }
Example #5
0
 public function show()
 {
     $postdata = $this->get_query_parameters();
     $buffer_key = md5(serialize($postdata));
     $output = $this->buffer->select($buffer_key);
     $output = $output ? json_decode($output, 1) : array();
     if (!$output) {
         $json_data = postCurl(CLOUND_TRAIN_API, $postdata);
         $result = json_decode($json_data, 1);
         if ($result['ResponseStatus']['Errors']) {
             $output['Message'] = $result['ResponseStatus']['Errors'][0]['Message'];
             $output['RecordCount'] = 0;
         }
         $output = array();
         $response = $result['ResponseBody'];
         $output['RecordCount'] = count($response['TrainItems']);
         $output['Data'] = $response ? changeTrainData($response, $postdata['DepartDate']) : array();
         $this->buffer->replace($buffer_key, json_encode($output));
     }
     echo json_encode($output);
     exit;
 }
Example #6
0
function getChatRecordForPage($ql, $limit = 0, $cursor)
{
    if (!empty($ql)) {
        $url = $GLOBALS['base_url'] . 'chatmessages?ql=' . $ql . '&limit=' . $limit . '&cursor=' . $cursor;
    }
    $header = array(getToken());
    $result = postCurl($url, '', $header, "GET");
    $cursor = $result["cursor"];
    writeCursor("chatfile.txt", $cursor);
    //var_dump($GLOBALS['cursor'].'00000000000000');
    return $result;
}
 function sendFile($filePath, $from = "admin", $target_type, $target, $filename, $length, $ext)
 {
     $result = $this->uploadFile($filePath);
     $uri = $result['uri'];
     $uuid = $result['entities'][0]['uuid'];
     $shareSecret = $result['entities'][0]['share-secret'];
     $url = $GLOBALS['base_url'] . 'messages';
     $body['target_type'] = $target_type;
     $body['target'] = $target;
     $options['type'] = "file";
     $options['url'] = $uri . '/' . $uuid;
     $options['filename'] = $filename;
     $options['length'] = $length;
     $options['secret'] = $shareSecret;
     $body['msg'] = $options;
     $body['from'] = $from;
     $body['ext'] = $ext;
     $b = json_encode($body);
     $header = array(getToken());
     //$b=json_encode($body,true);
     $result = postCurl($url, $b, $header);
     return $result;
 }
Example #8
0
 public function select_by_train_station()
 {
     $parameters = array('start' => $this->input['offset'] ? intval($this->input['offset']) : 0, 'chezhan' => trim($this->input['depart_city']), 'fchezhan' => $this->input['fchezhan'] ? intval($this->input['fchezhan']) : 15, 'ActionName' => 'chezhan');
     if (!$parameters['chezhan']) {
         $this->errorOutput(UNKNOWN_TRAIN_STATION);
     }
     $buffer_key = md5(serialize($parameters));
     $output = $this->buffer->select($buffer_key);
     $output = $output ? json_decode($output, 1) : array();
     if (!$output) {
         $html = postCurl(TRAIN_API2, $parameters);
         if (!$html) {
             $this->errorOutput(GET_DATA_ERROR);
         }
         $match = array();
         preg_match_all('/(.*?)<div\\s{0,}class="ct">(.*?)<\\/div>(.*?)/is', $html, $match);
         $output = array();
         if ($match) {
             $_tmp = array();
             preg_match('/\\s*<p>.*<b>(\\d*?)<\\/b>(.*?)<\\/p>\\s*/is', $match[2][0], $_tmp);
             $total = $_tmp[1];
             $_tmp = array();
             preg_match_all('/\\s*<tr>{0,1}(.*?)<td\\s.*?>.*?<a\\s.*?>(.*?)<\\/a>.*?<br\\/>(.*?)<\\/td>.*?<td\\s.*?>(.*?)<br\\/>(.*?)<\\/td>.*?<td\\s.*?>(.*?)<\\/td>.*?<\\/tr>?\\s*/is', $match[2][0], $_tmp);
             if (is_array($_tmp[2])) {
                 foreach ($_tmp[2] as $k => $v) {
                     $train_code = explode(' ', $v);
                     $train_station = explode('-', $_tmp[3][$k]);
                     $seats = explode('<br/>', $_tmp[6][$k]);
                     $seat = array();
                     foreach ($seats as $vs) {
                         if (trim($vs)) {
                             preg_match('/\\s*(.*?)(\\d+\\.?\\d+)(.*)/', $vs, $matchs);
                             list(, $seat_type, $price) = $matchs;
                             $seat[] = array('SeatTypeName' => trim($seat_type), 'Price' => $price);
                         }
                     }
                     $data[$k] = array('IsCanBook' => 0, 'TrainName' => trim($train_code[0]), 'BeginPortName' => trim($train_station[0]), 'DepartPort' => trim($train_station[0]), 'DepartTime' => trim($_tmp[4][$k]), 'EndPortName' => trim($train_station[1]), 'StartTime' => trim($_tmp[4][$k]), 'TrainTypeName' => trim($_tmp[5][$k]), 'SeatList' => $seat);
                 }
             }
             $output['total'] = $total;
             $output['data'] = $data;
             $this->buffer->replace($buffer_key, json_encode($output));
         }
     }
     $this->addItem($output);
     $this->output();
 }
 /**
  * post 刷新access_token
  */
 public function refreshAccessToken($refresh_token)
 {
     if (empty($refresh_token)) {
         die('The refresh_token cannot be empty');
     }
     //$url = "appid=".$this->openid."&grant_type=refresh_token&refresh_token=".$refresh_token;
     //$res = json_decode(getCurl($url),true);
     $url = "https://api.weixin.qq.com/sns/oauth2/refresh_token?";
     $arr = array('appid' => $this->appid, 'grant_type' => 'refresh_token', 'refresh_token' => $refresh_token);
     $res = json_decode(postCurl($url, $arr), true);
     return $res;
 }
Example #10
0
 public function proxySend($proxy_url, $proxy_key)
 {
     if (!$proxy_url || !$proxy_key) {
         return false;
     }
     $self_proxy_key = get_option('ext_function_mail_proxy_selfkey');
     if ($self_proxy_key == $proxy_key) {
         return false;
     }
     //can not proxy to self;
     $req = "page_id=mail-proxy&proxy_key={$proxy_key}";
     $req .= "&flag=" . $this->flag;
     $req .= "&smtpserver=" . $this->smtpserver;
     $req .= "&smtpserverport=" . $this->smtpserverport;
     $req .= "&smtpusermail=" . $this->smtpusermail;
     $req .= "&smtpuser="******"&smtppass="******"&smtpemailto=" . urlencode($this->smtpemailto);
     $req .= "&mailsubject=" . urlencode($this->mailsubject);
     $req .= "&mailbody=" . urlencode($this->mailbody);
     $response = postCurl($proxy_url, $req);
     if (!$response) {
         $response = getCurl($proxy_url, $req);
     }
     if ($proxy_key != trim($response)) {
         return false;
     }
     return $response;
 }
Example #11
0
<?php

$postUrl = $_COOKIE['postFormURL'];
// Setting URL to POST to
$tableValue = $_GET['tableValue'];
// Setting form input fields as 'name' => 'value'
$postFields = array('group1' => $tableValue, 'username' => 'zeke', 'password' => 'coys');
echo postCurl($postUrl, $postFields);
function postCurl($url, $postFields)
{
    $ch = curl_init();
    // Initialising cURL
    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    // $cookie = 'cookie.txt';  // Setting a cookie file to store cookie
    // curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);  // Setting cookiejar
    // curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);  // Setting cookiefile
    curl_setopt($ch, CURLOPT_URL, $userAgent);
    // Show my user agent to the owner
    curl_setopt($ch, CURLOPT_URL, $url);
    // Setting URL to POST to
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // Setting cURL's option to NOT return the webpage data
    curl_setopt($ch, CURLOPT_POST, 1);
    // Setting method as POST
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
    // Setting POST fields as array
    $data = curl_exec($ch);
    // Executing the cURL request and assigning the returned data to the $data variable
    curl_close($ch);
    // Closing cURL
Example #12
0
$url = "http://doodle.com/api1/polls/yux8uhbvb96htt2n";
$out = getCurl($url, $in_params, false);
?>
<code>
	<?php 
echo htmlentities($out);
?>
</code>  
<?php 
//
// 4. Create a new poll
//
echo "<hr><b>Create a new poll</b><br>";
$first = '<poll xmlns="http://doodle.com/xsd1"> <type>TEXT</type> <hidden>false</hidden> <levels>2</levels> <title>' . date(DATE_RFC822) . 'PPP</title> <description>yum!</description> <initiator> <name>Paul</name> </initiator> <options> <option>Pasta</option> <option>Pizza</option> <option>Polenta</option> </options> </poll>';
$url = "http://doodle.com/api1/polls";
$response = postCurl($url, $in_params, $first, true);
echo "<br><br><br>";
//  print_r(curl_getinfo($curl));
echo "Response:\n" . print_r($response) . "<br>";
echo "Select your date";
?>

<script src="jscalendar/mootools.v1.11.js" type="text/javascript"></script>
<script src="jscalendar/nogray_date_calendar_vs1_min.js" type="text/javascript"></script>

<script language="javascript">
	window.addEvent("domready", function(){
		var today = new Date();
											
		var calender4 = new Calendar("calendar4", null, {visible:true,
														startDay:1,