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) { $output = array(); if ($postdata) { $param = ''; foreach ($postdata as $k => $v) { $param .= '&' . $k . '=' . $v; } $url = CLOUND_FLIGHT_API . '?' . ltrim($param, '&'); } $jsondata = curlRequest($url); $data = json_decode($jsondata, 1); if (!$data) { $output['Message'] = '对不起,暂时无法查询此航班信息'; } if ($data['ResponseStatus']['Errors']) { $output['Message'] = $data['ResponseStatus']['Errors']; } $response = $this->changeFlightData($data); $output['Data'] = $response ? $response : array(); $this->buffer->replace($buffer_key, json_encode($output)); } echo json_encode($output); exit; }
/** * 模拟城市接口 * Enter description here ... */ private function analog() { if (!defined('CLOUND_AIRPORTS_CITY_API') || !CLOUND_AIRPORTS_CITY_API) { return ''; } $city_json = curlRequest(CLOUND_AIRPORTS_CITY_API); if (!$city_json) { $city_json = curlRequest(CLOUND_AIRPORTS_CITY_API); } $city_data = json_decode($city_json, true); if (is_array($city_data['cities'])) { foreach ($city_data['cities'] as $key => $val) { $cities[] = array('city_id' => strval($val['id']), 'city_name' => strval($val['name']), 'city_name_en' => strval($val['py']), 'city_name_jp' => strval($val['jp']), 'city_code' => strval($val['code']), 'air_port_code' => strval($val['portCode']), 'air_port_name' => strval($val['portName']), 'first_letter' => strval($val['initial']), 'flag' => strval($val['flag'])); } } if ($cities) { $fields = array('city_id', 'city_name', 'city_name_en', 'city_name_jp', 'city_code', 'air_port_code', 'air_port_name', 'first_letter', 'flag'); $sql = 'REPLACE INTO ' . DB_PREFIX . 'airports_city(' . implode(',', $fields) . ') values'; foreach ($cities as $key => $val) { $sql .= '(' . '""' . ', "' . addslashes($val['city_name']) . '", "' . addslashes($val['city_name_en']) . '", "' . addslashes($val['city_name_jp']) . '", "' . addslashes($val['city_code']) . '", "' . addslashes($val['air_port_code']) . '", "' . addslashes($val['air_port_name']) . '", "' . addslashes($val['first_letter']) . '", "' . addslashes($val['flag']) . '" ),'; } $sql = trim($sql, ','); $this->db->query($sql); } return $cities; }
function reqLogin() { $fields = array("kid" => '', "uni" => $GLOBALS["serverUrl"], "login" => $GLOBALS["user"]["login"], "pass" => $GLOBALS["user"]["pass"]); $pagina = curlRequest($GLOBALS["loginUrl"], $fields, $GLOBALS["cookie_file"]); if (!$pagina) { $this->error = true; $this->intentos++; } else { $this->error = false; } }
public function query($user_number = '', $month = '') { if (!$user_number || !$month) { return false; } $url = WATER_API . '&code=' . $user_number . '&month=' . $month; $data = curlRequest($url); if (!$data) { return false; } return $data; }
function fetch_airports_city() { if (!defined('AIRPORTS_CITY_API') || !AIRPORTS_CITY_API) { return ''; } $city_json = curlRequest(AIRPORTS_CITY_API); if (!$city_json) { $city_json = curlRequest(AIRPORTS_CITY_API); } $city_data = json_decode($city_json, true); $cities = array(); if (is_array($city_data['Data'])) { unset($city_data['Data'][0]); //字段含义 foreach ($city_data['Data'] as $key => $val) { $cities[] = array('city_id' => strval($val[0]), 'city_name' => strval($val[1]), 'city_name_en' => strval($val[2]), 'city_name_jp' => strval($val[3]), 'city_code' => strval($val[4]), 'air_port_code' => strval($val[5]), 'air_port_name' => strval($val[6]), 'first_letter' => strval($val[7]), 'flag' => strval($val[8])); } } //hg_pre($cities); if ($cities) { $fields = array('city_id', 'city_name', 'city_name_en', 'city_name_jp', 'city_code', 'air_port_code', 'air_port_name', 'first_letter', 'flag'); $sql = 'REPLACE INTO ' . DB_PREFIX . 'airports_city(' . implode(',', $fields) . ') values'; foreach ($cities as $key => $val) { $sql .= '(' . $val['city_id'] . ', "' . addslashes($val['city_name']) . '", "' . addslashes($val['city_name_en']) . '", "' . addslashes($val['city_name_jp']) . '", "' . addslashes($val['city_code']) . '", "' . addslashes($val['air_port_code']) . '", "' . addslashes($val['air_port_name']) . '", "' . addslashes($val['first_letter']) . '", "' . addslashes($val['flag']) . '" ),'; } $sql = trim($sql, ','); $this->db->query($sql); } return $cities; }
/** * This function Creates a new authorization for this app */ function signup_github() { //get request , either code from github, or login request if ($_SERVER['REQUEST_METHOD'] == 'GET') { //authorised at github if (isset($_GET['code'])) { $code = $_GET['code']; $fields = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'code' => $code); $postvars = ''; foreach ($fields as $key => $value) { $postvars .= $key . "=" . $value . "&"; } $data = array('url' => 'https://github.com/login/oauth/access_token', 'data' => $postvars, 'header' => array("Content-Type: application/x-www-form-urlencoded", "Accept: application/json"), 'method' => 'POST'); $gitResponce = json_decode(curlRequest($data)); if ($gitResponce->access_token) { $data = array('url' => 'https://api.github.com/user?access_token=' . $gitResponce->access_token, 'header' => array("Content-Type: application/x-www-form-urlencoded", "User-Agent: " . APP_NAME, "Accept: application/json"), 'method' => 'GET'); $gitUser = json_decode(curlRequest($data)); $signup_data = array('username' => $gitUser->login, 'email' => $gitUser->email, 'source' => 'github', 'token' => $gitResponce->access_token); signup_login_user($signup_data); } } } }
public function menuAction() { $this->getToken(); $data = ['button' => [['type' => 'click', 'name' => '菜单1', 'key' => '/index/say'], ['type' => 'click', 'name' => '菜单二', 'key' => '/index/test'], ['type' => 'view', 'name' => '菜单三', 'url' => $this->setUrl('/index/test1')]]]; $url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $this->token; echo "<pre>"; var_dump(curlRequest($url, json_encode($data, JSON_UNESCAPED_UNICODE))); }
/** * 创建二维码ticket * 每次创建二维码ticket需要提供一个开发者自行设定的参数(scene_id),分别介绍临时二维码和永久二维码的创建二维码ticket过程。 * * @param int $scene_id 场景值ID,临时二维码时为32位整型,永久二维码时最大值为1000 * @param int $type 二维码类型,0为临时,1为永久 * @param int $expire 该二维码有效时间,以秒为单位。 最大不超过1800。 */ public function createQrcode($scene_id, $type = 0, $expire = 1800) { if (!$this->access_token && !$this->checkAuth()) { return false; } $data = array(); $data['action_info'] = array('scene' => array('scene_id' => $scene_id)); $data['action_name'] = $type == 0 ? 'QR_SCENE' : 'QR_LIMIT_SCENE'; if ($type == 0) { $data['expire_seconds'] = $expire; } $result = curlRequest(self::API_URL_PREFIX . self::QRCODE_CREATE_URL . 'access_token=' . $this->access_token, $this->jsonEncode($data), 'post'); if ($result) { $jsonArr = json_decode($result, true); if (!$jsonArr || isset($jsonArr['errcode']) && $jsonArr['errcode'] > 0) { $this->error($jsonArr); } else { return $jsonArr; } } return false; }
include_once 'curl.php'; if (isset($_GET['search_keyword'])) { $searchKeyword = isset($_GET['search_keyword']) ? trim($_GET['search_keyword']) : ''; $condition = isset($_GET['condition']) ? trim($_GET['condition']) : 'All'; $anyCategory = isset($_GET['any_category']) ? $_GET['any_category'] : ''; $responseGroup = 'SearchBins, Images,ItemAttributes, Reviews'; $page = isset($_GET['page']) ? $_GET['page'] : 1; $xml_response = curlRequest($searchKeyword, $condition, $anyCategory, $responseGroup, $page); $objXml = new SimpleXMLElement($xml_response); $objResult = $objXml->children()->Items->Item; $objSearchBins = $objXml->children()->Items->SearchBinSets->SearchBinSet->Bin; /*print('<pre>'); print_r($objXml); print('</pre>');*/ $responseGroup = 'OfferSummary'; $xml_response = curlRequest($searchKeyword, $condition, $anyCategory, $responseGroup, $page); $objXml = new SimpleXMLElement($xml_response); $offerSummery = $objXml->children()->Items->Item; $TotalPages = (int) $objXml->children()->Items->TotalPages; $arrConditions = array(); foreach ($offerSummery as $conditions) { foreach ($conditions->OfferSummary as $key => $val) { foreach ($val as $key1 => $val1) { if ($key1 != 'LowestNewPrice' && $key1 != 'LowestUsedPrice') { $arrConditions[$key1][] = (int) $val1; } } } } $TotalNew = isset($arrConditions['TotalNew']) ? '(' . array_sum($arrConditions['TotalNew']) . ')' : ''; $TotalUsed = isset($arrConditions['TotalUsed']) ? '(' . array_sum($arrConditions['TotalUsed']) . ')' : '';
<ul class="actions"> <li> <?php require_once 'githubConf.php'; require_once 'functions.php'; if (isset($_GET['code'])) { $fields = array('client_id' => clientID, 'client_secret' => clientSecret, 'code' => $_GET['code']); $postvars = ''; foreach ($fields as $key => $value) { $postvars .= $key . "=" . $value . "&"; } $data = array('url' => 'https://github.com/login/oauth/access_token', 'data' => $postvars, 'header' => array("Content-Type: application/x-www-form-urlencoded", "Accept: application/json"), 'method' => 'POST'); $gitResponce = json_decode(curlRequest($data)); if ($gitResponce->access_token) { $data = array('url' => 'https://api.github.com/user?access_token=' . $gitResponce->access_token, 'header' => array("Content-Type: application/x-www-form-urlencoded", "User-Agent: " . appName, "Accept: application/json"), 'method' => 'GET'); $gitUser = json_decode(curlRequest($data)); header("Location: hello.php"); } else { echo "Some error occured try again"; } } else { echo '<a href="https://github.com/login/oauth/authorize?scope=user:email&client_id=' . clientID . '" title="Login with Github"> <img src="GitHub-Logo.png" /> </a>'; } ?> <!-- <a href="#" class="button big">Log in</a> --> </li> </ul> </section>
global $wpdb; $sql="SELECT domain, path FROM up_blogs WHERE archived='0' AND deleted ='0' LIMIT 0,300"; $res = mysqli_query($cn,$sql); while($r=mysqli_fetch_object($res)){ $blogs[]=$r; } //$blogs = $wpdb->get_results($sql); //print_r($blogs); /*$d=curlRequest('http://upfit.de/cron-job/?preview=true'); echo $d;*/ //echo 'Cron job page link for all sites'; foreach($blogs as $blog) { $url = "https://" . $blog->domain . ($blog->path ? $blog->path : '/') . 'cron-job/?preview=true'; echo $url . "<br>"; $d=curlRequest($url); echo $d; //wp_remote_get( 'http://lanetteam.com:8018/html/upfit/cron-job' ); }/* function get_order_details($url){ //echo $url; $ch = curl_init(); //$timeout = 5; curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch,CURLOPT_URL,$url); //curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); $data = curl_exec($ch); if($data === false) {
public function get_all_airline() { $page = floor($this->input['offset'] / 10) + 1; if ($this->input['offset'] % 10 != 0) { $page = ceil($this->input['offset'] / 10) + 1; } $parameters = array('dep' => $this->input['depart_citycode'] ? $this->input['depart_citycode'] : '', 'arr' => $this->input['arrive_citycode'] ? $this->input['arrive_citycode'] : '', 'airline' => $this->input['airline'] ? $this->input['airline'] : 'ALL', 'page' => $page); $buffer_key = md5(serialize($parameters)); $outdata = $this->buffer->select($buffer_key); $outdata = $outdata ? json_decode($outdata, 1) : array(); if (!$outdata) { $url = AIRLINE_API2 . '?dep=' . $parameters['dep'] . '&arr=' . $parameters['arr'] . '&airline=' . $parameters['airline'] . '&page=' . $page; $html = curlRequest($url); if (!$html) { $this->errorOutput(GET_DATA_ERROR); } $match = array(); preg_match_all('/(.*?)<div\\s{0,}class="comm">(.*?)<\\/div><\\/div>/is', $html, $match); $match[2][0] = $match[2][0] . '</div>'; $output = array(); if ($match) { //匹配航班信息 $_tmpx = array(); preg_match_all('/\\s{0,}<div\\s{0,}class="line"><span\\s{0,}style="color:\\s{0,}\\#\\w{6};">\\s{0,} (.*?)<\\/span>(.*?)<\\/div>/is', $match[2][0], $_tmpx); if ($_tmpx) { foreach ($_tmpx[2] as $key => $val) { preg_match_all('/(?:.*?)<td\\s{0,}(?:.*?)>\\s{0,}(?:<span\\s{0,}(?:.*?)>){0,1}(.*?)(?:<\\/span>){0,1}<\\/td>(?:.*?)/is', $val, $_tmp1[]); } } if (is_array($_tmp1) && $_tmp1) { foreach ($_tmp1 as $key => $val) { $vv = $val[1]; $output[$key] = array('FlightNo' => $_tmpx[1][$key], 'DepartAirportCode' => trim($vv[0]), 'EstimateDeparTime' => '--:--', 'EstimateArriveTime' => '--:--', 'ArriveAirportCode' => trim($vv[5]), 'DepartTerminal' => trim($vv[1]), 'ActualDepartTime' => trim($vv[3]), 'ActualArriveTime' => trim($vv[8]), 'ArriveTerminal' => trim($vv[6]), 'PlanDepartTime' => trim($vv[2]), 'PlanArriveTime' => trim($vv[7]), 'StopAirport' => '', 'StopCity' => '', 'AirCompanyName' => '', 'StatusRemark' => trim($vv[9])); } } //匹配航班状态的颜色 preg_match_all('/(?:.*?)<div\\s{0,}class="line">((?:.*?)<span\\s{0,}class="(.*?)">(?:.*?)<\\/span>){3}(?:.*?)<\\/div>(?:.*?)/is', $match[2][0], $_tmp); if ($_tmp[2] && is_array($_tmp[2])) { foreach ($_tmp[2] as $key => $val) { switch ($val) { case 'fly': $StatusRemarkColor = '95B23D'; break; case 'cacel': $StatusRemarkColor = 'D81921'; break; case 'delay': $StatusRemarkColor = 'F7931E'; break; default: $StatusRemarkColor = '95B23D'; } $output[$key]['StatusRemarkColor'] = $StatusRemarkColor; } } /*****计算数据总数*******/ preg_match_all('/\\s*<div\\s{0,}id="Panel1">(?:.*?) (\\d+)\\/(\\d+)(?:.*?)<\\/div>(?:.*?)/is', $html, $page); if ($page[2][0]) { $total_page = $page[2][0]; //总页数 $last_url = AIRLINE_API2 . '?dep=' . $parameters['dep'] . '&arr=' . $parameters['arr'] . '&airline=' . $parameters['airline'] . '&page=' . $total_page; $last_html = curlRequest($last_url); preg_match_all('/(?:.*?)<div\\s{0,}class="line">(.*?)<\\/div>(?:.*?)/is', $last_html, $last_page_match); $last_page_number = count($last_page_match[1]); if ($total_page > 0) { $total = ($total_page - 1) * 10 + $last_page_number; } //计算total } else { $total = count($output); } /*****计算数据总数*******/ } $outdata['total'] = $total; $outdata['data'] = $output; $this->buffer->replace($buffer_key, json_encode($outdata)); } if (!$outdata) { $this->errorOutput(NO_DATA); } $this->addItem($outdata); $this->output(); }
if ($data && $method == 'POST') { $option[CURLOPT_POST] = 1; $option[CURLOPT_POSTFIELDS] = $data; } $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt_array($ch, $option); $response = curl_exec($ch); if (curl_errno($ch) > 0) { return curl_error($ch); } curl_close($ch); return $response; } if ($_POST) { $content = curlRequest($_POST['url'], $_POST['data']); echo $content; die; } ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <title>接口测试</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta charset="UTF-8"> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css"rel="stylesheet">
function despegue($campos) { return curlRequest($GLOBALS["urlFleetF"], $campos, $GLOBALS["cookie_file"]); }
function revoke() { $id = $this->input->get_post('id'); $data['status'] = 'RVK'; $data['issueid'] = $id; $json = curlRequest(JIF . "/smstaskcontrol/cancle_issue", '{"issueId":' . $id . '}'); $ret = json_decode($json, TRUE); if (!isset($ret['errcode']) || $ret['errcode'] != '0') { echo json_encode(array('status' => '2', 'msg' => '撤销失败')); exit; } $result = $this->model->update($data); if ($result) { $this->task_model->update(['status' => 'RVK'], ['issueid' => $id, 'status' => 'CRT']); echo json_encode(array('status' => '1', 'msg' => '撤销成功')); exit; } else { echo json_encode(array('status' => '2', 'msg' => '撤销失败')); exit; } }
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ""); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4); $output = curl_exec($ch); if (!$output) { echo curl_error($ch); exit; } curl_close($ch); return $output; } /** Generate URL **/ $sonarCompleteURL = $sonarBaseURL . "/" . $sonarAction . "?&componentKeys=" . $sonarComponentKey . "&severities=" . $sonarServerity . "&format=" . $sonarReportFormat; $curlOutput = curlRequest($sonarCompleteURL); $allSonarIssues = json_decode($curlOutput, true); $sonarAction = "do_action"; foreach ($allSonarIssues['issues'] as $key => $value) { if (array_key_exists('attr', $value) && array_key_exists('jira-issue-key', $value['attr'])) { } else { $jiraIssueLinkURL[] = $sonarBaseURL . "/" . $sonarAction . "?&actionKey=link-to-jira&issue=" . $value['key']; } } if (count($jiraIssueLinkURL) > 0) { echo "-------------------------------------------------------------------------------------------\n"; echo "\t\t\tLinking Sonar Issues to JIRA \t\t\t\t\t\t\t\t \n"; echo "-------------------------------------------------------------------------------------------\n"; foreach ($jiraIssueLinkURL as $key => $value) { $jiraOutputAPI = curlRequestPost($value); $allJiraissues = json_decode($jiraOutputAPI, true);