PHP code example of hypejunction / http-parser

1. Go to this page and download the library: Download hypejunction/http-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hypejunction / http-parser example snippets




$client = new \GuzzleHttp\Client([
	'headers' => [
		'User-Agent' => 'MyApp LinkPreview/1.0 (+https://myapp.example)',
	],
	'timeout' => 5,
	'connect_timeout' => 5,
]);

$parser = new \hypeJunction\Parser($client);

$data = $parser->parse('https://example.com/some/page');

$parser = new \hypeJunction\Parser($client, [
	// Maximum number of bytes read from a response body (default: 2 MB)
	'max_body_length' => 2097152,

	// URL schemes the parser is allowed to fetch (default: http, https)
	'allowed_schemes' => ['http', 'https'],

	// Allow requests to private/reserved IP ranges (default: false — see SECURITY.md)
	'allow_private_hosts' => false,

	// Maximum number of <img> tags verified with an HTTP request per document (default: 10)
	'max_image_checks' => 10,

	// Maximum number of discovered oEmbed endpoints fetched per document (default: 3)
	'max_oembed_fetches' => 3,

	// Maximum number of redirects to follow; each target is re-validated (default: 5)
	'max_redirects' => 5,

	// Extra Guzzle request options merged into every request
	'request_options' => [],
], $logger); // optional PSR-3 logger