send() public static méthode

Send a cURL request
public static send ( Unirest\Method | string $method, string $url, mixed $body = null, array $headers = [], string $username = null, string $password = null ) : unirest\Response
$method Unirest\Method | string HTTP method to use
$url string URL to send the request to
$body mixed request body
$headers array additional headers to send
$username string Authentication username (deprecated)
$password string Authentication password (deprecated)
Résultat unirest\Response
Exemple #1
0
 public function make_request($options)
 {
     $injector = Injector::getInstance();
     $url = $options['url'];
     $method = $options['method'];
     $headers = $options['headers'];
     $body = isset($options['body']) ? $options['body'] : '';
     $response = null;
     if (isset($options['qs'])) {
         $qs = http_build_query($options['qs']);
         $url .= '?' . $qs;
     }
     $url = str_replace('%2C', ',', $url);
     if (isset($headers['Content-Type']) && $headers['Content-Type'] == 'application/json' && is_array($body)) {
         $body = json_encode($body);
     }
     Request::verifyPeer($injector->ssl_verification);
     $response = Request::send($options['method'], $url, $body, $headers);
     return $response;
 }