php|architect's Guide to Web Scraping with PHP - Wind Business ...
php|architect's Guide to Web Scraping with PHP - Wind Business ...
php|architect's Guide to Web Scraping with PHP - Wind Business ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
68 ” PEAR::HTTP_Client<br />
}<br />
?><br />
}<br />
}<br />
default:<br />
PEAR::raiseError(’Unhandled error: ’ . $event);<br />
• Declare a construc<strong>to</strong>r that calls the parent construc<strong>to</strong>r and performs any<br />
needed cus<strong>to</strong>m logic.<br />
• Declare the update method <strong>with</strong> the signature sho wn. $subject is the request<br />
or client instance <strong>to</strong> which the listener is attached. $event is a string containing<br />
one of the events sho wn in the switch statement.<br />
• $data is data specific <strong>to</strong> events related <strong>to</strong> reception of the server response.<br />
• Request and response events occur <strong>with</strong>in HTTP_Request instances.<br />
events occur <strong>with</strong>in HTTP_Client instances.<br />
Client<br />
• N ote that not all events need <strong>to</strong> be handled, only those <strong>with</strong> which you are<br />
concerned.<br />
The attach method in HTTP_Request takes a single parameter, a listener instance.<br />
The equivalent method in HTTP_Client takes two parameters, a required listener instance<br />
and an optional boolean flag. When the latter is false (which it is by default),<br />
attached listeners will not be propagated <strong>to</strong> requests created <strong>with</strong>in the client instance.<br />
That is, a listener added will not be notified of request and response events,<br />
only client events. To have an added listener receive all events, explicitly specify the<br />
$propagate parameter <strong>to</strong> be true when calling attach.<br />
W rap-U p<br />
F or more information on the PEAR packages co vered here, see these resources listed<br />
belo w .<br />
• http://pear.php.net/manual/en/package.http.http-request.php