|  | Posted by Chung Leong on 12/10/05 19:51 
In theory, you can create a stream context, then attach a callbackfunction to it to receive notifications:
 
 $context = stream_context_create(array());
 stream_context_set_params($context, array('notification' =>
 'stream_callback'));
 $f = fopen("http://www.google.com/", "rb", false, $context);
 
 The parameters passed to the function are as followed:
 
 function stream_callback(
 $notifycode,
 $severity,
 $xmsg,
 $xcode,
 $bytes_sofar,
 $bytes_max)
 
 Notification codes are defined as such:
 
 1 = RESOLVE
 2 = CONNECT
 3 = AUTH_REQUIRED
 4 = MIME_TYPE_IS
 5 = FILE_SIZE_IS
 6 = REDIRECTED
 7 = PROGRESS
 8 = COMPLETED
 9 = FAILURE
 10 = AUTH_RESULT
 
 Severity codes:
 
 0 = INFO
 1 = WARNING
 2 = ERROR
 
 In practice, however, the PHP stream API is somewhat of a
 work-in-progress. Not everything is listed above is actually
 implemented. As of PHP 4.3.6, the callback doesn't receive
 notifications for the resolve stage.
  Navigation: [Reply to this message] |