Sample code for 30+ languages & platforms
PHP Requires Chilkat v11.0.0+

Example: Http.HttpNoBody method

Demonstrates how to use the HttpNoBody method to send HTTP requests without a request body (e.g., GET, DELETE, HEAD) and receive the response in a Chilkat Http response object.

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\Http;
use Chilkat2\HttpResponse;

$http = new Http();
$resp = new HttpResponse();

// Send a DELETE request to https://api.example.com/users/123
$url = 'https://api.example.com/users/123';
try {
    $http->HttpNoBody('DELETE', $url, $resp);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

echo 'Response Status Code: ', $resp->StatusCode, "\n";
echo "Response body:\n";
echo $resp->BodyStr, "\n";