本文整理汇总了PHP中Http::setMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::setMethod方法的具体用法?PHP Http::setMethod怎么用?PHP Http::setMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::setMethod方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Adds the WordPress hook during construction.
*
* @param \Herbert\Framework\Application $app
* @param \Herbert\Framework\Http $http
*/
public function __construct(Application $app, Http $http)
{
$this->app = $app;
$this->http = $http;
if (!is_admin()) {
return;
}
add_action('admin_menu', [$this, 'boot']);
$http->setMethod($http->get('_method'), $old = $http->method());
if (!in_array($http->method(), self::$methods)) {
$http->setMethod($old);
}
if ($http->method() !== 'GET') {
add_action('init', [$this, 'bootEarly']);
}
}
示例2: Http
<?php
// Include the Http Class
include_once 'class.http.php';
// Instantiate it
$http = new Http();
// Let's not use cURL
$http->useCurl(false);
// POST method
$http->setMethod('POST');
// POST parameters
$http->addParam('user_name', 'yourusername');
$http->addParam('password', 'yourpassword');
// Referrer
$http->setReferrer('https://yourproject.projectpath.com/login');
// Get basecamp dashboard (HTTPS)
$http->execute('https://yourproject.projectpath.com/login/authenticate');
// Show result page or error if occurred
echo $http->error ? $http->error : $http->result;
示例3: delete
/**
* @param $url string Url a la cual se generara la peticion
* @param $auth string Cadena de autentificacion
* @param $data string Parametros a enviar
* @param array $headers Arreglo de headers http
* @return mixed
* @throws \Exception
*/
public static function delete($url, $auth, $data = null, $headers = array())
{
$ch = Http::initHttp($url);
Http::setMethod($ch, 'DELETE');
Http::setAuth($ch, $auth);
if (!empty($data)) {
Http::setPostFields($ch, $data);
}
Http::setHeaders($ch, $headers);
$response = Http::execHttp($ch);
if (empty($response)) {
throw new \Exception("Respuesta vacia");
} else {
return $response;
}
}
示例4: request
function request($url = "", $method = "GET", $params = NULL)
{
//#4 FIX: Don't use token on PLAINTEXT signature
$token = $this->signature instanceof OAuthSignatureMethod_PLAINTEXT ? NULL : $this->token;
$request = OAuthRequest::from_consumer_and_token($this->consumer, $token, $method, $url, $params);
$request->sign_request($this->signature, $this->consumer, $token);
$http = new Http();
$http->setMethod($method);
switch ($method) {
case 'GET':
$url = $request->to_url();
break;
default:
parse_str($request->to_postdata(), $params);
$http->setParams($params);
$url = $request->get_normalized_http_url();
break;
}
$http->execute($url);
return $http->error ? die($http->error) : $http->result;
}
示例5: api_trafficrequest_cb
function api_trafficrequest_cb($id, $type)
{
if (getconfig_var('allow_statistical_info') != 1) {
return true;
}
// Include the Http Class
require_once MAD_PATH . '/modules/http/class.http.php';
// Instantiate it
$http = new Http();
$http->setMethod('GET');
$http->addParam('install_id', getconfig_var('installation_id'));
$http->addParam('requestid', get_actual_tr_id($id));
$http->addParam('status', $type);
$http->execute('http://network.madserve.org/request_accept.php');
if ($http->error) {
return false;
}
return true;
}
示例6: compileJS
function compileJS($scripts)
{
// make this a config option?
$baseUrl = "assets/js/";
$http = new Http();
$http->setMethod('GET');
// sort results
//ksort_recursive( $minify );
// record signature
//$md5 = "";
$cache_path = $this->_getCacheDir() . "{$baseUrl}";
// FIX: create the dir if not available
if (!is_dir($cache_path)) {
mkdir($cache_path, 0775, true);
}
// process each group
foreach ($scripts as $name => $group) {
$first = current($group);
$result = "";
$timestamp = 0;
// go to next group if minify flag is not true
if (!$first["data"]['minify']) {
continue;
}
$min = new UglifyJS();
$min->cacheDir($cache_path);
$min->compiler($GLOBALS['config']['admin']['uglify_service']);
// get the encoding from the first member of the group
$encode = $first["data"]["encode"];
// loop through the group and add the files
foreach ($group as $script) {
// the move the domain from the script (if available)
// check if it's a local url
$href = $script["src"];
$local = substr($href, 0, 4) !== "http" || substr($href, 0, 2) !== "//";
if ($local) {
$href = url($href);
}
$result .= $http->execute($href);
// get modified time
$mtime = urlmtime($href);
// compare with newest file in the group
if ($timestamp < $mtime) {
$timestamp = $mtime;
}
//$src = str_replace( array(url(), cdn() ),"", $script["src"] );
// remove leading slash
//$src = ltrim($src,'/');
//$md5 .= md5_file($file);
}
// compress signatures of all files
$md5 = md5($result);
// set timestamp
$min->timestamp($timestamp);
//contents of each group are saved in a tmp file
$tmp_file = $cache_path . "tmp.{$md5}.js";
file_put_contents($tmp_file, $result);
// add tmp file
$min->add($tmp_file);
//$min->setFile( "$name.$md5.min" );
$min->setFile("{$name}");
if (!DEBUG) {
$min->quiet()->hideDebugInfo();
}
// condition the method of minification here...
switch ($encode) {
case "whitespace":
$min->whitespaceOnly();
break;
case "simple":
$min->simpleMode();
break;
case "advanced":
$min->advancedMode();
break;
default:
$min->simpleMode();
break;
}
$min->write();
$min->clear();
// add the signature in the group
//$scripts[$name][]["data"]["md5"] = $md5;
}
return $scripts;
}