public function init($request_url) { $this->reset(); $this->_request_url = $request_url; $this->_source = make_request($this->_request_url); $this->_prepare4csdn(); }
public function init($request_url) { $this->_request_url = $request_url; $this->_has_next_page = false; $this->_next_page_url = ''; $this->_post_list = array(); $this->_source = make_request($this->_request_url); }
/** * ShopEx licence * * @copyright Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn) * @license http://ecos.shopex.cn/ ShopEx License */ function theme_widget_city_ip(&$setting, &$render) { // $limit = ($setting['limit'])?$setting['limit']:6; // $brand_list = app::get('b2c')->model('brand')->getList('*',array(),0,$limit,'ordernum desc'); //static $realip; //获取数据库城市地区 $obj_regions_op = kernel::service('ectools_regions_apps', array('content_path' => 'ectools_regions_operation')); $ret["area"] = $obj_regions_op->getRegionById(); if (isset($_SERVER)) { if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { if (isset($_SERVER["HTTP_CLIENT_IP"])) { $realip = $_SERVER["HTTP_CLIENT_IP"]; } else { $realip = $_SERVER["REMOTE_ADDR"]; } } } else { if (getenv("HTTP_X_FORWARDED_FOR")) { $realip = getenv("HTTP_X_FORWARDED_FOR"); } else { if (getenv("HTTP_CLIENT_IP")) { $realip = getenv("HTTP_CLIENT_IP"); } else { $realip = getenv("REMOTE_ADDR"); } } } $getServerURL = "http://ip.taobao.com/service/getIpInfo.php"; $params["ip"] = $realip; //$params["ip"]="60.30.131.255"; //根据IP地址获取所在城市信息,默认深圳市 $ret["region"] = "广东省"; $ret["realcity"] = "广州市"; $ipresultobj = json_decode(make_request($getServerURL, $params, 1)); if ($ipresultobj) { if ($ipresultobj->code == 1) { $ret["region"] = "广东省"; $ret["realcity"] = "广州市"; } else { $ret["region"] = $ipresultobj->data->region; $ret["realcity"] = $ipresultobj->data->city; } if ($ipresultobj->data->region === "") { $ret["region"] = "广东省"; $ret["realcity"] = "广州市"; } } //setcookie("region",$ret["region"],"3600*24"); return $ret; }
function get_content($manual_path, $url, $title, $parent_dir) { $data = json_decode(make_request($url), 1); $data = $data['data']; $content = ''; foreach ($data as $key => $value) { $content .= $value['content']; } $replace = $parent_dir ? '..' : '.'; $tpl = file_get_contents("{$manual_path}/public/book.tpl"); $tpl = str_replace('{%ROOT}', $replace, $tpl); $tpl = str_replace('{%title}', iconv('UTF-8', 'GB2312', $title), $tpl); $content = str_replace('{%s}', iconv('UTF-8', 'GB2312', $content), $tpl); return $content; }
/** * @param $package * * @throws Exception */ function download_package($package) { if (file_exists(__DIR__ . '/' . basename($package))) { return true; } $data = make_request($package); // Set the filesystem target $target = __DIR__ . '/' . basename($package); // Write the response to the filesystem if (!file_put_contents($target, $data)) { throw new \Exception(); } }
<?php header('Content-Type: text/html;charset=utf-8'); /* Сюда приходят данные с сервера */ $output = []; /* Основная функция */ function make_request($xml, &$output) { /* НАЧАЛО ЗАПРОСА */ $options = ['http' => ['method' => "POST", 'header' => "User-Agent: PHPRPC/1.0\r\n" . "Content-Type: text/xml\r\n" . "Content-length: " . strlen($xml) . "\r\n\n", 'content' => "{$xml}"]]; $context = stream_context_create($options); $retval = file_get_contents('http://phpoopsite.local/xml-rpc/xml-rpc-server.php', false, $context); /* КОНЕЦ ЗАПРОСА */ $data = xmlrpc_decode($retval); if (is_array($data) && xmlrpc_is_fault($data)) { $output = $data; } else { $output = unserialize(base64_decode($data)); } } /* Идентификатор статьи */ $id = 1; $request_xml = xmlrpc_encode_request('getNewsById', array($id)); make_request($request_xml, $output); /* Вывод результата */ var_dump($output);
<?php /** /* This code verifies that the authorization succeded. **/ //Include libraries require '../facebook.php'; require '../appengine_functions.php'; //Initialize Facebook's PHP library $config = array('appId' => '140229329376512', 'secret' => '198fb6f72dfb3a029d410d98e3beb203', 'cookie' => true, 'domain' => true); $facebook_client = new Facebook($config); //Initialize variables $app_id = $facebook_client->getAppId(); $app_secret = $facebook_client->getApiSecret(); $CANVAS_URL = 'http://apps.facebook.com/russ_myfirstapp/'; //Get the access token from Facebook by supplying the App ID & Secret. $params = array('client_id' => $app_id, 'type' => 'client_cred', 'client_secret' => $app_secret); $url = "https://graph.facebook.com/oauth/access_token"; $access_token = make_request($url, $params); // creates a POST request with $params as the parameters. $access_token = substr($access_token, strpos($access_token, "=") + 1, strlen($access_token)); //If the access token is not present, something went wrong //so display an error, else, redirect to canvas page. if ($access_token) { header('Location: ' . $CANVAS_URL); } else { echo 'An error occurred'; } exit;
/** * Makes an HTTP request. This method can be overriden by subclasses if * developers want to do fancier things or use something other than curl to * make the request. * * @param String $url the URL to make the request to * @param Array $params the parameters to use for the POST body * @param CurlHandler $ch optional initialized curl handle * @return String the response text */ protected function makeRequest($url, $params, $ch = null) { //HACK TO ROUTE REQUESTS THROUGH URLFETCH - APP ENGINE $data = make_request($url, $params); return $data; }
<html> <body bgcolor="white"> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="GET"> Login: <input type="text" name="login"><br /> Password: <input type="password" name="password"><br /> <input type="submit" value="Login"> </form> <?php define('__SERVER__', "localhost"); define('__PORT__', 80); if (count($_GET)) { include "/home/rei/www/pres2/presentations/slides/web_services/client.inc.php"; $ret = make_request(); if (parse_response($ret) === TRUE) { echo "Login Successful"; } else { echo "Authentication Failure"; } } ?> </body> </html>
make_request($request_xml, $arMessage, $num); /* Добавляем пустой элемент для вывода пустой строки */ $arMessage[] = ""; /* Номер необходимой полки */ $num = "2"; $request_xml = xmlrpc_encode_request('getStock', array($userid, $num)); make_request($request_xml, $arMessage, $num); /* Добавляем пустой элемент для вывода пустой строки */ $arMessage[] = ""; /* Номер необходимой полки */ $num = "3"; $request_xml = xmlrpc_encode_request('getStock', array($userid, $num)); make_request($request_xml, $arMessage, $num); /* Добавляем пустой элемент для вывода пустой строки */ $arMessage[] = ""; /* Такой полки нет */ $num = "4"; $request_xml = xmlrpc_encode_request('getStock', array($userid, $num)); make_request($request_xml, $arMessage, $num); /* Добавляем пустой элемент для вывода пустой строки */ $arMessage[] = ""; /* Неправильное число аргументов */ $num = "4"; $request_xml = xmlrpc_encode_request('getStock', array($num)); make_request($request_xml, $arMessage, $num); /* Вывод результата */ print '<pre>'; foreach ($arMessage as $message) { print $message . "\n"; } print '</pre>';
$ret = stream_get_contents($stream); $meta = stream_get_meta_data($stream); if ($ret) { $ret = json_decode($ret); } return array($ret, $meta); } function myJson_encode($str) { return str_replace('\\/', '/', json_encode($str)); } //Endpoint details $basicLogin = '******'; $basicPass = '******'; //NOTE: do not include "statements" as part of the endpoint URL. This is added later. $endpoint = 'https://cloud.scorm.com/ScormEngineInterface/TCAPI/public/'; //statement vars $actorName = 'Example McExampleson'; $actorEmail = '*****@*****.**'; $verbId = 'http://adlnet.gov/expapi/verbs/created'; $verbDisplay = 'created'; $activityURL = 'http://example.adlnet.gov/xapi/example/activity'; $activityName = 'Example activity'; $activityDesc = 'An example activity for example purposes'; //build the statement $statement = buildStatement($actorName, $actorEmail, $verbId, $verbDisplay, $activityURL, $activityName, $activityDesc); //send the statement - returns the response and metadata list($resp, $meta) = make_request($statement, $endpoint, $basicLogin, $basicPass); echo '<p>response: ' . $resp[0] . '</p>'; //This is the statement ID echo '<p>meta: ' . myJson_encode($meta) . '</p>';
private function get_region() { //区域 $obj_regions_op = kernel::service('ectools_regions_apps', array('content_path' => 'ectools_regions_operation')); $ret["area"] = $obj_regions_op->getRegionById(); if (isset($_SERVER)) { if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { if (isset($_SERVER["HTTP_CLIENT_IP"])) { $realip = $_SERVER["HTTP_CLIENT_IP"]; } else { $realip = $_SERVER["REMOTE_ADDR"]; } } } else { if (getenv("HTTP_X_FORWARDED_FOR")) { $realip = getenv("HTTP_X_FORWARDED_FOR"); } else { if (getenv("HTTP_CLIENT_IP")) { $realip = getenv("HTTP_CLIENT_IP"); } else { $realip = getenv("REMOTE_ADDR"); } } } $getServerURL = "http://ip.taobao.com/service/getIpInfo.php"; $params["ip"] = $realip; //$params["ip"]="60.30.131.255"; //根据IP地址获取所在城市信息,默认深圳市 $ret["region"] = "广东省"; //$ret["realcity"]="广州市"; $ipresultobj = json_decode(make_request($getServerURL, $params, 1)); if ($ipresultobj) { if ($ipresultobj->code == 1) { $ret["region"] = "广东省"; $ret["realcity"] = "广州市"; } else { $ret["region"] = $ipresultobj->data->region; $ret["realcity"] = $ipresultobj->data->city; } if ($ipresultobj->data->region === "") { $ret["region"] = "广东省"; $ret["realcity"] = "广州市"; } } //setcookie("region",$ret["region"],"3600*24"); return $ret; }
$whitelist_sql .= " LIMIT {$offset}, {$page_by}"; $stmt = mysqli_query($conn, $whitelist_sql); if (!$stmt) { throw new Exception('Could not get list of queries from database'); } while ($row = mysqli_fetch_assoc($stmt)) { $rows[] = $row; } $stmt = mysqli_query($conn, $count_sql); $count = mysqli_fetch_array($stmt); $count = $count[0]; if ($page_by >= 0) { $pages = $count / $page_by; unset($_REQUEST['page_by']); for ($i = 0; $i < $pages; ++$i) { $linklist = "<a href='" . make_request(array('page' => $i + 1)) . "'>" . ($i + 1) . "</a> "; } } function make_request($add) { $r = ""; foreach ($_REQUEST as $k => $v) { if ($r) { $r .= '&'; } $r .= urlencode($k) . "=" . urlencode($v); } foreach ($add as $k => $v) { if ($r) { $r .= '&'; }
<?php session_start(); require_once '../build/oAuth.php'; require_once '../build/functions.php'; if (isset($_SESSION['access_token'])) { $status = "Hacked Raspberry Pi turned into artificial pancreas http://www.businessinsider.com/hacked-raspberry-pi-artificial-pancreas-2015-8"; $parameters = array('status' => $status); $request = make_request('POST', $parameters, 'statuses/update'); print_r($request); } else { redirect('./build/reqirect.php'); }
function download($Url, $Method = "GET", $Referer = "", $PostHash = null, $ResponseFileName = null) { $PostData = array(); if ($PostHash) { foreach ($PostHash as $key => $value) { $PostData[] = $key . '=' . $value; } } try { do { $Request = make_request($Url, $Method, $Referer, implode('&', $PostData), $host, $port); if ($open) { fclose($open); } $open = fsockopen($host, $port, $errno, $errst, 30); fputs($open, $Request); $StatusLine = fgets($open); $Response = $StatusLine . fget_response($open); if ($ResponseFileName) { file_put_contents($ResponseFileName, $Response); } $StatusCode = extract_statusline_code($Response); switch ($StatusCode) { case 303: $Method = 'GET'; case 301: case 302: $Referer = $Url; $Url = extract_location($Response); $PostData = array(); } } while ($StatusCode != 200 and $StatusCode < 400); while (!feof($open)) { $buffer = fgets($open, 4096); if ($buffer === false) { break; } $Html .= $buffer; } fclose($open); } catch (E_NOTICE $e) { echo "Notice raised: " . $e->getMessage(); } update_cookies($Url, $Response); if (preg_match("/transfer\\-encoding\\: chunked/i", $Response)) { $Html = transfer_encoding_chunked_decode($Html); } if (preg_match("/Content\\-Encoding\\: gzip/i", $Response)) { $Response = preg_replace("/Content\\-Encoding: gzip\\s+/isU", "", $Response); $Html = gzinflate(substr($Html, 10)); } return $Html; }
<?php error_reporting(0); include_once 'lib/parse.php'; // Find the dependencies from the js file $depsRes = array(); if (!empty($_POST['file']) && is_array($_POST['file'])) { $files = array(); foreach ($_POST['file'] as $file) { if (!empty($file)) { $files[] = make_request($file); } } if (isset($_FILES['file']['tmp_name']) && is_array($_FILES['file']['tmp_name'])) { foreach ($_FILES['file']['tmp_name'] as $key => $name) { $files[] = file_get_contents($name); } } $jsDeps = new JSDeps(); $jsDeps->setTests(require 'lib/mootoolsDependencies.php'); // print_r($files); foreach ($files as $file) { if (!empty($file)) { $deps1 = $jsDeps->getDependencies($file); foreach ($deps1 as $dep) { $depsRes[$dep] = $dep; } } } $mooScripts = json_decode(file_get_contents('scripts.json'), true); // Complete the dependencies
return $ax; } /****************************************************************** * Function: Attach Simple Registration * Description: Creates simple registration OpenID extension request * to allow capturing of simple profile attributes ******************************************************************/ function attach_sreg() { //create simple registration request $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email')); //return sreg request return $sreg_request; } /****************************************************************** * Function: Attach PAPE * Description: Creates PAPE policy OpenID extension request to * inform server of policy standards ******************************************************************/ function attach_pape() { //capture pape policies passed in via openid form $policy_uris = $_GET['policies']; //create pape policy request $pape_request = new Auth_OpenID_PAPE_Request($policy_uris); //return pape request return $pape_request; } //initiate the OpenID request make_request();
$data = xmlrpc_decode($retval); if (is_array($data) && xmlrpc_is_fault($data)) { $arrMessage[] = "Невозможно получить данные о полке номер {$code}"; $arrMessage[] = "Error Code: " . $data['faultCode']; $arrMessage[] = "Error Message: " . $data['faultString']; } else { $arrMessage[] = $data; } } /* Код необходимой полки */ $code = "a"; $request_xml = xmlrpc_encode_request('getStock', $code); make_request($request_xml, $arrMessage, $code); /* Добавляем пустой элемент для вывода пустой строки */ $arrMessage[] = ""; /* Код необходимой полки */ $code = "c"; $request_xml = xmlrpc_encode_request('getStock', $code); make_request($request_xml, $arrMessage, $code); /* Добавляем пустой элемент для вывода пустой строки */ $arrMessage[] = ""; /* Код необходимой полки (которой нет) */ $code = "x"; $request_xml = xmlrpc_encode_request('getStock', $code); make_request($request_xml, $arrMessage, $code); /* Вывод результата */ print '<pre>'; foreach ($arrMessage as $message) { print $message . "\n"; } print '</pre>';
$image = 'image.png'; $mime = 'image/png'; $delegator = 'http://posterous.com/api2/upload.json'; $x_auth_service_provider = 'https://api.twitter.com/1/account/verify_credentials.json'; generate_verify_header($tmhOAuth, $x_auth_service_provider); $params = prepare_request($tmhOAuth, $x_auth_service_provider, $image, $mime); // post to OAuth Echo provider $code = make_request($tmhOAuth, $delegator, $params, false, true); if ($code != 200) { tmhUtilities::pr('There was an error communicating with the delegator.'); tmhUtilities::pr($tmhOAuth); die; } $resp = json_decode($tmhOAuth->response['response']); $params = array('status' => 'I just OAuth echoed a picture: ' . $resp->url); $code = make_request($tmhOAuth, $tmhOAuth->url('1/statuses/update'), $params, true, false); if ($code == 200) { tmhUtilities::pr('Picture OAuth Echo\'d!'); tmhUtilities::pr(json_decode($tmhOAuth->response['response'])); } else { tmhUtilities::pr('There was an error from Twitter.'); tmhUtilities::pr($tmhOAuth); die; } function generate_verify_header($tmhOAuth, $x_auth_service_provider) { // generate the verify crendentials header -- BUT DON'T SEND // we prevent the request because we're not the ones sending the verify_credentials request, the delegator is $tmhOAuth->config['prevent_request'] = true; $tmhOAuth->request('GET', $x_auth_service_provider); $tmhOAuth->config['prevent_request'] = false;
/** * It should have more then 1 item in the headers set cookie array * * @return void * @author Christopher Cowan * @test **/ public function It_should_have_more_then_1_item_in_the_headers_set_cookie_array() { $response = make_request($this->test_url, 'GET'); $this->assertGreaterThan(1, count($response['headers']['Set-Cookie'])); $this->assertGreaterThan(1, count($response['cookies'])); }