PHP Classes

File: examples/xml.php

Recommend this page to a friend!
  Classes of Lars Moelleken   PHP httpful Request   examples/xml.php   Download  
File: examples/xml.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP httpful Request
Send and process HTTP requests using handler class
Author: By
Last change:
Date: 3 years ago
Size: 970 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
Httpful\Mime;

require
__DIR__ . '/../vendor/autoload.php';

$uri = 'https://www.w3schools.com/xml/note.xml';

// -------------------------------------------------------

$responseComplex = (new \Httpful\Client())
    ->
sendRequest(
        (
            new \
Httpful\Request(
                \
Httpful\Http::GET,
               
Mime::PLAIN
           
)
        )->
followRedirects()
    );

// -------------------------------------------------------

$responseMedium = \Httpful\Client::get_request($uri)
    ->
withExpectedType(Mime::PLAIN)
    ->
followRedirects()
    ->
send();

// -------------------------------------------------------

$responseSimple = \Httpful\Client::get($uri);

// -------------------------------------------------------

if (
   
$responseComplex->getRawBody() === $responseSimple->getRawBody()
    &&
   
$responseComplex->getRawBody() === $responseMedium->getRawBody()
) {
    echo
' - same output - ';
}