PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Nitesh Apte   Multiple URL Asynchronous Call PHP   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Multiple URL Asynchronous Call PHP
Run many tasks in parallel sending HTTP requests
Author: By
Last change:
Date: 18 hours ago
Size: 621 bytes
 

Contents

Class file image Download
<?php
include 'AsyncExecutor.php';

// Example usage:

// Create an instance of AsyncUrlFetcher with max concurrency of 3
$asyncExecutor = new AsyncExecutor(3);

// Add multiple URLs to be fetched
$asyncExecutor->addUrl('https://jsonplaceholder.typicode.com/posts');
$asyncExecutor->addUrl('https://jsonplaceholder.typicode.com/comments');
$asyncExecutor->addUrl('https://jsonplaceholder.typicode.com/albums');
$asyncExecutor->addUrl('https://jsonplaceholder.typicode.com/photos');
$asyncExecutor->addUrl('https://jsonplaceholder.typicode.com/todos');

// Fetch all URLs asynchronously
$asyncExecutor->fetchAllUrls();
?>