03.02.2014 Views

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 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

76 ” Zend_Http_Client<br />

getLastResponse would return null. If you don’t needed the additional availability of<br />

the response, turning this off can lessen resource usage.<br />

Cookies<br />

Zend_Http_Client will accept manually specified cookie name-value pairs via its<br />

setCookie method, but by default will not au<strong>to</strong>matically retain response cookies and<br />

resend them in subsequent requests. To have it do so , simply call setCookieJar <strong>with</strong><br />

no parameters. This will cause an instance of the default cookie handling class,<br />

Zend_Http_CookieJar, <strong>to</strong> be implicitly instantiated.<br />

If you need access <strong>to</strong> cookie data for something other than propagating it <strong>to</strong> subsequent<br />

requests, there are a few ways <strong>to</strong> do so . Cookies can be accessed individually<br />

via the cookie jar’s getCookie method, the required parameters for which are a URI<br />

and a cookie name.<br />

<br />

N ote that the URI includes a scheme (http://), a domain (localhost.example), and<br />

a path (/). A single cookie jar instance can s<strong>to</strong>re cookie data for multiple domains<br />

and multiple paths on the same domain. In cases where the latter capability is not<br />

used, the path / can be specified so that all cookies set on the specified domain<br />

are available <strong>to</strong> all paths under that domain. The getMatchingCookies method of<br />

Zend_Http_CookieJar allo ws cookies <strong>to</strong> be accessed collectively based on these criteria<br />

and returns an array of Zend_Http_Cookie objects by default. See belo w for examples.<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!