Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/flow-flo.../libs/mashape/unirest-.../src/Unirest
File: Request.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Unirest;
[2] Fix | Delete
[3] Fix | Delete
class Request
[4] Fix | Delete
{
[5] Fix | Delete
private static $cookie = null;
[6] Fix | Delete
private static $cookieFile = null;
[7] Fix | Delete
private static $curlOpts = array();
[8] Fix | Delete
private static $defaultHeaders = array();
[9] Fix | Delete
private static $handle = null;
[10] Fix | Delete
private static $jsonOpts = array();
[11] Fix | Delete
private static $socketTimeout = null;
[12] Fix | Delete
private static $verifyPeer = true;
[13] Fix | Delete
private static $verifyHost = true;
[14] Fix | Delete
[15] Fix | Delete
private static $auth = array (
[16] Fix | Delete
'user' => '',
[17] Fix | Delete
'pass' => '',
[18] Fix | Delete
'method' => CURLAUTH_BASIC
[19] Fix | Delete
);
[20] Fix | Delete
[21] Fix | Delete
private static $proxy = array(
[22] Fix | Delete
'port' => false,
[23] Fix | Delete
'tunnel' => false,
[24] Fix | Delete
'address' => false,
[25] Fix | Delete
'type' => CURLPROXY_HTTP,
[26] Fix | Delete
'auth' => array (
[27] Fix | Delete
'user' => '',
[28] Fix | Delete
'pass' => '',
[29] Fix | Delete
'method' => CURLAUTH_BASIC
[30] Fix | Delete
)
[31] Fix | Delete
);
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Set JSON decode mode
[35] Fix | Delete
*
[36] Fix | Delete
* @param bool $assoc When TRUE, returned objects will be converted into associative arrays.
[37] Fix | Delete
* @param integer $depth User specified recursion depth.
[38] Fix | Delete
* @param integer $options Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRING is supported (default is to cast large integers as floats)
[39] Fix | Delete
* @return array
[40] Fix | Delete
*/
[41] Fix | Delete
public static function jsonOpts($assoc = false, $depth = 512, $options = 0)
[42] Fix | Delete
{
[43] Fix | Delete
return self::$jsonOpts = array($assoc, $depth, $options);
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Verify SSL peer
[48] Fix | Delete
*
[49] Fix | Delete
* @param bool $enabled enable SSL verification, by default is true
[50] Fix | Delete
* @return bool
[51] Fix | Delete
*/
[52] Fix | Delete
public static function verifyPeer($enabled)
[53] Fix | Delete
{
[54] Fix | Delete
return self::$verifyPeer = $enabled;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Verify SSL host
[59] Fix | Delete
*
[60] Fix | Delete
* @param bool $enabled enable SSL host verification, by default is true
[61] Fix | Delete
* @return bool
[62] Fix | Delete
*/
[63] Fix | Delete
public static function verifyHost($enabled)
[64] Fix | Delete
{
[65] Fix | Delete
return self::$verifyHost = $enabled;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Set a timeout
[70] Fix | Delete
*
[71] Fix | Delete
* @param integer $seconds timeout value in seconds
[72] Fix | Delete
* @return integer
[73] Fix | Delete
*/
[74] Fix | Delete
public static function timeout($seconds)
[75] Fix | Delete
{
[76] Fix | Delete
return self::$socketTimeout = $seconds;
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Set default headers to send on every request
[81] Fix | Delete
*
[82] Fix | Delete
* @param array $headers headers array
[83] Fix | Delete
* @return array
[84] Fix | Delete
*/
[85] Fix | Delete
public static function defaultHeaders($headers)
[86] Fix | Delete
{
[87] Fix | Delete
return self::$defaultHeaders = array_merge(self::$defaultHeaders, $headers);
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Set a new default header to send on every request
[92] Fix | Delete
*
[93] Fix | Delete
* @param string $name header name
[94] Fix | Delete
* @param string $value header value
[95] Fix | Delete
* @return string
[96] Fix | Delete
*/
[97] Fix | Delete
public static function defaultHeader($name, $value)
[98] Fix | Delete
{
[99] Fix | Delete
return self::$defaultHeaders[$name] = $value;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Clear all the default headers
[104] Fix | Delete
*/
[105] Fix | Delete
public static function clearDefaultHeaders()
[106] Fix | Delete
{
[107] Fix | Delete
return self::$defaultHeaders = array();
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* Set curl options to send on every request
[112] Fix | Delete
*
[113] Fix | Delete
* @param array $options options array
[114] Fix | Delete
* @return array
[115] Fix | Delete
*/
[116] Fix | Delete
public static function curlOpts($options)
[117] Fix | Delete
{
[118] Fix | Delete
return self::mergeCurlOptions(self::$curlOpts, $options);
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* Set a new default header to send on every request
[123] Fix | Delete
*
[124] Fix | Delete
* @param string $name header name
[125] Fix | Delete
* @param string $value header value
[126] Fix | Delete
* @return string
[127] Fix | Delete
*/
[128] Fix | Delete
public static function curlOpt($name, $value)
[129] Fix | Delete
{
[130] Fix | Delete
return self::$curlOpts[$name] = $value;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
/**
[134] Fix | Delete
* Clear all the default headers
[135] Fix | Delete
*/
[136] Fix | Delete
public static function clearCurlOpts()
[137] Fix | Delete
{
[138] Fix | Delete
return self::$curlOpts = array();
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* Set a Mashape key to send on every request as a header
[143] Fix | Delete
* Obtain your Mashape key by browsing one of your Mashape applications on https://www.mashape.com
[144] Fix | Delete
*
[145] Fix | Delete
* Note: Mashape provides 2 keys for each application: a 'Testing' and a 'Production' one.
[146] Fix | Delete
* Be aware of which key you are using and do not share your Production key.
[147] Fix | Delete
*
[148] Fix | Delete
* @param string $key Mashape key
[149] Fix | Delete
* @return string
[150] Fix | Delete
*/
[151] Fix | Delete
public static function setMashapeKey($key)
[152] Fix | Delete
{
[153] Fix | Delete
return self::defaultHeader('X-Mashape-Key', $key);
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
/**
[157] Fix | Delete
* Set a cookie string for enabling cookie handling
[158] Fix | Delete
*
[159] Fix | Delete
* @param string $cookie
[160] Fix | Delete
*/
[161] Fix | Delete
public static function cookie($cookie)
[162] Fix | Delete
{
[163] Fix | Delete
self::$cookie = $cookie;
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
/**
[167] Fix | Delete
* Set a cookie file path for enabling cookie handling
[168] Fix | Delete
*
[169] Fix | Delete
* $cookieFile must be a correct path with write permission
[170] Fix | Delete
*
[171] Fix | Delete
* @param string $cookieFile - path to file for saving cookie
[172] Fix | Delete
*/
[173] Fix | Delete
public static function cookieFile($cookieFile)
[174] Fix | Delete
{
[175] Fix | Delete
self::$cookieFile = $cookieFile;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
/**
[179] Fix | Delete
* Set authentication method to use
[180] Fix | Delete
*
[181] Fix | Delete
* @param string $username authentication username
[182] Fix | Delete
* @param string $password authentication password
[183] Fix | Delete
* @param integer $method authentication method
[184] Fix | Delete
*/
[185] Fix | Delete
public static function auth($username = '', $password = '', $method = CURLAUTH_BASIC)
[186] Fix | Delete
{
[187] Fix | Delete
self::$auth['user'] = $username;
[188] Fix | Delete
self::$auth['pass'] = $password;
[189] Fix | Delete
self::$auth['method'] = $method;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
/**
[193] Fix | Delete
* Set proxy to use
[194] Fix | Delete
*
[195] Fix | Delete
* @param string $address proxy address
[196] Fix | Delete
* @param integer $port proxy port
[197] Fix | Delete
* @param integer $type (Available options for this are CURLPROXY_HTTP, CURLPROXY_HTTP_1_0 CURLPROXY_SOCKS4, CURLPROXY_SOCKS5, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5_HOSTNAME)
[198] Fix | Delete
* @param bool $tunnel enable/disable tunneling
[199] Fix | Delete
*/
[200] Fix | Delete
public static function proxy($address, $port = 1080, $type = CURLPROXY_HTTP, $tunnel = false)
[201] Fix | Delete
{
[202] Fix | Delete
self::$proxy['type'] = $type;
[203] Fix | Delete
self::$proxy['port'] = $port;
[204] Fix | Delete
self::$proxy['tunnel'] = $tunnel;
[205] Fix | Delete
self::$proxy['address'] = $address;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
/**
[209] Fix | Delete
* Set proxy authentication method to use
[210] Fix | Delete
*
[211] Fix | Delete
* @param string $username authentication username
[212] Fix | Delete
* @param string $password authentication password
[213] Fix | Delete
* @param integer $method authentication method
[214] Fix | Delete
*/
[215] Fix | Delete
public static function proxyAuth($username = '', $password = '', $method = CURLAUTH_BASIC)
[216] Fix | Delete
{
[217] Fix | Delete
self::$proxy['auth']['user'] = $username;
[218] Fix | Delete
self::$proxy['auth']['pass'] = $password;
[219] Fix | Delete
self::$proxy['auth']['method'] = $method;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
/**
[223] Fix | Delete
* Send a GET request to a URL
[224] Fix | Delete
*
[225] Fix | Delete
* @param string $url URL to send the GET request to
[226] Fix | Delete
* @param array $headers additional headers to send
[227] Fix | Delete
* @param mixed $parameters parameters to send in the querystring
[228] Fix | Delete
* @param string $username Authentication username (deprecated)
[229] Fix | Delete
* @param string $password Authentication password (deprecated)
[230] Fix | Delete
* @return Response
[231] Fix | Delete
*/
[232] Fix | Delete
public static function get($url, $headers = array(), $parameters = null, $username = null, $password = null)
[233] Fix | Delete
{
[234] Fix | Delete
return self::send(Method::GET, $url, $parameters, $headers, $username, $password);
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* Send a HEAD request to a URL
[239] Fix | Delete
* @param string $url URL to send the HEAD request to
[240] Fix | Delete
* @param array $headers additional headers to send
[241] Fix | Delete
* @param mixed $parameters parameters to send in the querystring
[242] Fix | Delete
* @param string $username Basic Authentication username (deprecated)
[243] Fix | Delete
* @param string $password Basic Authentication password (deprecated)
[244] Fix | Delete
* @return Response
[245] Fix | Delete
*/
[246] Fix | Delete
public static function head($url, $headers = array(), $parameters = null, $username = null, $password = null)
[247] Fix | Delete
{
[248] Fix | Delete
return self::send(Method::HEAD, $url, $parameters, $headers, $username, $password);
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
/**
[252] Fix | Delete
* Send a OPTIONS request to a URL
[253] Fix | Delete
* @param string $url URL to send the OPTIONS request to
[254] Fix | Delete
* @param array $headers additional headers to send
[255] Fix | Delete
* @param mixed $parameters parameters to send in the querystring
[256] Fix | Delete
* @param string $username Basic Authentication username
[257] Fix | Delete
* @param string $password Basic Authentication password
[258] Fix | Delete
* @return Response
[259] Fix | Delete
*/
[260] Fix | Delete
public static function options($url, $headers = array(), $parameters = null, $username = null, $password = null)
[261] Fix | Delete
{
[262] Fix | Delete
return self::send(Method::OPTIONS, $url, $parameters, $headers, $username, $password);
[263] Fix | Delete
}
[264] Fix | Delete
[265] Fix | Delete
/**
[266] Fix | Delete
* Send a CONNECT request to a URL
[267] Fix | Delete
* @param string $url URL to send the CONNECT request to
[268] Fix | Delete
* @param array $headers additional headers to send
[269] Fix | Delete
* @param mixed $parameters parameters to send in the querystring
[270] Fix | Delete
* @param string $username Basic Authentication username (deprecated)
[271] Fix | Delete
* @param string $password Basic Authentication password (deprecated)
[272] Fix | Delete
* @return Response
[273] Fix | Delete
*/
[274] Fix | Delete
public static function connect($url, $headers = array(), $parameters = null, $username = null, $password = null)
[275] Fix | Delete
{
[276] Fix | Delete
return self::send(Method::CONNECT, $url, $parameters, $headers, $username, $password);
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
/**
[280] Fix | Delete
* Send POST request to a URL
[281] Fix | Delete
* @param string $url URL to send the POST request to
[282] Fix | Delete
* @param array $headers additional headers to send
[283] Fix | Delete
* @param mixed $body POST body data
[284] Fix | Delete
* @param string $username Basic Authentication username (deprecated)
[285] Fix | Delete
* @param string $password Basic Authentication password (deprecated)
[286] Fix | Delete
* @return Response response
[287] Fix | Delete
*/
[288] Fix | Delete
public static function post($url, $headers = array(), $body = null, $username = null, $password = null)
[289] Fix | Delete
{
[290] Fix | Delete
return self::send(Method::POST, $url, $body, $headers, $username, $password);
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
/**
[294] Fix | Delete
* Send DELETE request to a URL
[295] Fix | Delete
* @param string $url URL to send the DELETE request to
[296] Fix | Delete
* @param array $headers additional headers to send
[297] Fix | Delete
* @param mixed $body DELETE body data
[298] Fix | Delete
* @param string $username Basic Authentication username (deprecated)
[299] Fix | Delete
* @param string $password Basic Authentication password (deprecated)
[300] Fix | Delete
* @return Response
[301] Fix | Delete
*/
[302] Fix | Delete
public static function delete($url, $headers = array(), $body = null, $username = null, $password = null)
[303] Fix | Delete
{
[304] Fix | Delete
return self::send(Method::DELETE, $url, $body, $headers, $username, $password);
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
/**
[308] Fix | Delete
* Send PUT request to a URL
[309] Fix | Delete
* @param string $url URL to send the PUT request to
[310] Fix | Delete
* @param array $headers additional headers to send
[311] Fix | Delete
* @param mixed $body PUT body data
[312] Fix | Delete
* @param string $username Basic Authentication username (deprecated)
[313] Fix | Delete
* @param string $password Basic Authentication password (deprecated)
[314] Fix | Delete
* @return Response
[315] Fix | Delete
*/
[316] Fix | Delete
public static function put($url, $headers = array(), $body = null, $username = null, $password = null)
[317] Fix | Delete
{
[318] Fix | Delete
return self::send(Method::PUT, $url, $body, $headers, $username, $password);
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
/**
[322] Fix | Delete
* Send PATCH request to a URL
[323] Fix | Delete
* @param string $url URL to send the PATCH request to
[324] Fix | Delete
* @param array $headers additional headers to send
[325] Fix | Delete
* @param mixed $body PATCH body data
[326] Fix | Delete
* @param string $username Basic Authentication username (deprecated)
[327] Fix | Delete
* @param string $password Basic Authentication password (deprecated)
[328] Fix | Delete
* @return Response
[329] Fix | Delete
*/
[330] Fix | Delete
public static function patch($url, $headers = array(), $body = null, $username = null, $password = null)
[331] Fix | Delete
{
[332] Fix | Delete
return self::send(Method::PATCH, $url, $body, $headers, $username, $password);
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
/**
[336] Fix | Delete
* Send TRACE request to a URL
[337] Fix | Delete
* @param string $url URL to send the TRACE request to
[338] Fix | Delete
* @param array $headers additional headers to send
[339] Fix | Delete
* @param mixed $body TRACE body data
[340] Fix | Delete
* @param string $username Basic Authentication username (deprecated)
[341] Fix | Delete
* @param string $password Basic Authentication password (deprecated)
[342] Fix | Delete
* @return Response
[343] Fix | Delete
*/
[344] Fix | Delete
public static function trace($url, $headers = array(), $body = null, $username = null, $password = null)
[345] Fix | Delete
{
[346] Fix | Delete
return self::send(Method::TRACE, $url, $body, $headers, $username, $password);
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
/**
[350] Fix | Delete
* This function is useful for serializing multidimensional arrays, and avoid getting
[351] Fix | Delete
* the 'Array to string conversion' notice
[352] Fix | Delete
* @param array|object $data array to flatten.
[353] Fix | Delete
* @param bool|string $parent parent key or false if no parent
[354] Fix | Delete
* @return array
[355] Fix | Delete
*/
[356] Fix | Delete
public static function buildHTTPCurlQuery($data, $parent = false)
[357] Fix | Delete
{
[358] Fix | Delete
$result = array();
[359] Fix | Delete
[360] Fix | Delete
if (is_object($data)) {
[361] Fix | Delete
$data = get_object_vars($data);
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
foreach ($data as $key => $value) {
[365] Fix | Delete
if ($parent) {
[366] Fix | Delete
$new_key = sprintf('%s[%s]', $parent, $key);
[367] Fix | Delete
} else {
[368] Fix | Delete
$new_key = $key;
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
if (!$value instanceof \CURLFile and (is_array($value) or is_object($value))) {
[372] Fix | Delete
$result = array_merge($result, self::buildHTTPCurlQuery($value, $new_key));
[373] Fix | Delete
} else {
[374] Fix | Delete
$result[$new_key] = $value;
[375] Fix | Delete
}
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
return $result;
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
/**
[382] Fix | Delete
* Send a cURL request
[383] Fix | Delete
* @param \Unirest\Method|string $method HTTP method to use
[384] Fix | Delete
* @param string $url URL to send the request to
[385] Fix | Delete
* @param mixed $body request body
[386] Fix | Delete
* @param array $headers additional headers to send
[387] Fix | Delete
* @param string $username Authentication username (deprecated)
[388] Fix | Delete
* @param string $password Authentication password (deprecated)
[389] Fix | Delete
* @throws \Unirest\Exception if a cURL error occurs
[390] Fix | Delete
* @return Response
[391] Fix | Delete
*/
[392] Fix | Delete
public static function send($method, $url, $body = null, $headers = array(), $username = null, $password = null)
[393] Fix | Delete
{
[394] Fix | Delete
self::$handle = curl_init();
[395] Fix | Delete
[396] Fix | Delete
if ($method !== Method::GET) {
[397] Fix | Delete
if ($method === Method::POST) {
[398] Fix | Delete
curl_setopt(self::$handle, CURLOPT_POST, true);
[399] Fix | Delete
} else {
[400] Fix | Delete
curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method);
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
curl_setopt(self::$handle, CURLOPT_POSTFIELDS, $body);
[404] Fix | Delete
} elseif (is_array($body)) {
[405] Fix | Delete
if (strpos($url, '?') !== false) {
[406] Fix | Delete
$url .= '&';
[407] Fix | Delete
} else {
[408] Fix | Delete
$url .= '?';
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
$url .= urldecode(http_build_query(self::buildHTTPCurlQuery($body)));
[412] Fix | Delete
}
[413] Fix | Delete
[414] Fix | Delete
$curl_base_options = [
[415] Fix | Delete
CURLOPT_URL => self::encodeUrl($url),
[416] Fix | Delete
CURLOPT_RETURNTRANSFER => true,
[417] Fix | Delete
CURLOPT_FOLLOWLOCATION => true,
[418] Fix | Delete
CURLOPT_MAXREDIRS => 10,
[419] Fix | Delete
CURLOPT_HTTPHEADER => self::getFormattedHeaders($headers),
[420] Fix | Delete
CURLOPT_HEADER => true,
[421] Fix | Delete
CURLOPT_SSL_VERIFYPEER => self::$verifyPeer,
[422] Fix | Delete
//CURLOPT_SSL_VERIFYHOST accepts only 0 (false) or 2 (true). Future versions of libcurl will treat values 1 and 2 as equals
[423] Fix | Delete
CURLOPT_SSL_VERIFYHOST => self::$verifyHost === false ? 0 : 2,
[424] Fix | Delete
// If an empty string, '', is set, a header containing all supported encoding types is sent
[425] Fix | Delete
CURLOPT_ENCODING => ''
[426] Fix | Delete
];
[427] Fix | Delete
[428] Fix | Delete
curl_setopt_array(self::$handle, self::mergeCurlOptions($curl_base_options, self::$curlOpts));
[429] Fix | Delete
[430] Fix | Delete
if (self::$socketTimeout !== null) {
[431] Fix | Delete
curl_setopt(self::$handle, CURLOPT_TIMEOUT, self::$socketTimeout);
[432] Fix | Delete
}
[433] Fix | Delete
[434] Fix | Delete
if (self::$cookie) {
[435] Fix | Delete
curl_setopt(self::$handle, CURLOPT_COOKIE, self::$cookie);
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
if (self::$cookieFile) {
[439] Fix | Delete
curl_setopt(self::$handle, CURLOPT_COOKIEFILE, self::$cookieFile);
[440] Fix | Delete
curl_setopt(self::$handle, CURLOPT_COOKIEJAR, self::$cookieFile);
[441] Fix | Delete
}
[442] Fix | Delete
[443] Fix | Delete
// supporting deprecated http auth method
[444] Fix | Delete
if (!empty($username)) {
[445] Fix | Delete
curl_setopt_array(self::$handle, array(
[446] Fix | Delete
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
[447] Fix | Delete
CURLOPT_USERPWD => $username . ':' . $password
[448] Fix | Delete
));
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
if (!empty(self::$auth['user'])) {
[452] Fix | Delete
curl_setopt_array(self::$handle, array(
[453] Fix | Delete
CURLOPT_HTTPAUTH => self::$auth['method'],
[454] Fix | Delete
CURLOPT_USERPWD => self::$auth['user'] . ':' . self::$auth['pass']
[455] Fix | Delete
));
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
if (self::$proxy['address'] !== false) {
[459] Fix | Delete
curl_setopt_array(self::$handle, array(
[460] Fix | Delete
CURLOPT_PROXYTYPE => self::$proxy['type'],
[461] Fix | Delete
CURLOPT_PROXY => self::$proxy['address'],
[462] Fix | Delete
CURLOPT_PROXYPORT => self::$proxy['port'],
[463] Fix | Delete
CURLOPT_HTTPPROXYTUNNEL => self::$proxy['tunnel'],
[464] Fix | Delete
CURLOPT_PROXYAUTH => self::$proxy['auth']['method'],
[465] Fix | Delete
CURLOPT_PROXYUSERPWD => self::$proxy['auth']['user'] . ':' . self::$proxy['auth']['pass']
[466] Fix | Delete
));
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
$response = curl_exec(self::$handle);
[470] Fix | Delete
$error = curl_error(self::$handle);
[471] Fix | Delete
$info = self::getInfo();
[472] Fix | Delete
[473] Fix | Delete
if ($error) {
[474] Fix | Delete
throw new Exception($error);
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
// Split the full response in its headers and body
[478] Fix | Delete
$header_size = $info['header_size'];
[479] Fix | Delete
$header = substr($response, 0, $header_size);
[480] Fix | Delete
$body = substr($response, $header_size);
[481] Fix | Delete
$httpCode = $info['http_code'];
[482] Fix | Delete
[483] Fix | Delete
return new Response($httpCode, $body, $header, self::$jsonOpts);
[484] Fix | Delete
}
[485] Fix | Delete
[486] Fix | Delete
public static function getInfo($opt = false)
[487] Fix | Delete
{
[488] Fix | Delete
if ($opt) {
[489] Fix | Delete
$info = curl_getinfo(self::$handle, $opt);
[490] Fix | Delete
} else {
[491] Fix | Delete
$info = curl_getinfo(self::$handle);
[492] Fix | Delete
}
[493] Fix | Delete
[494] Fix | Delete
return $info;
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
public static function getCurlHandle()
[498] Fix | Delete
{
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function