Location: PHPKode > scripts > Stream > example.php
<?php
require 'Stream.class.php';
require 'Stream_HTTP.class.php';
require 'Stream_HTTPS.class.php';

try
{
  $s = new Stream_HTTP;

  $s->addGetRequest('www.phpclasses.org', '/', 'phpclasses'); // named index
  $s->addGetRequest('www.google.com'); // numeric index

  $r = $s->doRequest(1); // only make one request at the same time. Leave empty for parallel requests
  $s->clearRequest(); // reset request queue

  // Display Content of phpclasses Site
  //print $r['result']['phpclasses'];

  // Or show headers returned from google.com
  header('Content-Type: text/plain');
  print_r($r['headers'][1]);


  // another example
  for ($i = 0; $i < 10; $i++)
  {
    // Add google.com 10 times 
    $s->addGetRequest('www.google.com', '/', 'google_'.$i);  
  }
  $s->timeout = 60; // increase timeout per single request
  $r = $s->doRequest(); // and fetch it parallel
  $s->clearRequest();
  var_dump($r);
}
catch(Exception $e)
{
  print $e->getMessage();
}
Return current item: Stream