![]() |
|
sfWebBrowserPlugin - 0.9.2Standalone HTTP client |
|
![]() |
188
users
Sign-in
to change your status |
The sfWebBrowserPlugin proposes an HTTP client capable of making web requests. The interface is similar to that of sfTestBrowser. |
| Name | Status | |
|---|---|---|
|
|
lead | moc.tcejorp-ynofmys <<ta>> ottoninaz.siocnarf |
Copyright (c) 2004-2006 Francois Zaninotto
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 1.1.2stable | MIT license | 1.1.2stable | 12/05/2009 |
| 1.1.1stable | MIT license | 1.1.1stable | 22/04/2009 |
| 1.1.0stable | MIT license | 1.1.0stable | 23/09/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 1.1.2stable | MIT license | 1.1.2stable | 12/05/2009 |
| 1.1.1stable | MIT license | 1.1.1stable | 22/04/2009 |
| 1.1.0stable | MIT license | 1.1.0stable | 23/09/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 1.1.2stable | MIT license | 1.1.2stable | 12/05/2009 |
| 1.1.1stable | MIT license | 1.1.1stable | 22/04/2009 |
| 1.1.0stable | MIT license | 1.1.0stable | 23/09/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 1.1.2stable | MIT license | 1.1.2stable | 12/05/2009 |
| 1.1.1stable | MIT license | 1.1.1stable | 22/04/2009 |
| 1.1.0stable | MIT license | 1.1.0stable | 23/09/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 1.1.2stable | MIT license | 1.1.2stable | 12/05/2009 |
| 1.1.1stable | MIT license | 1.1.1stable | 22/04/2009 |
| 1.1.0stable | MIT license | 1.1.0stable | 23/09/2008 |
| 1.0.1stable | MIT license | 1.0.1stable | 27/03/2007 |
| 1.0.0stable | MIT license | 1.0.0stable | 08/03/2007 |
| 0.9.6beta | MIT license | 0.9.6beta | 22/02/2007 |
| 0.9.5beta | MIT license | 0.9.5beta | 21/02/2007 |
| 0.9.4beta | MIT license | 0.9.4beta | 16/02/2007 |
| 0.9.3beta | MIT license | 0.9.3beta | 16/02/2007 |
| 0.9.2beta | MIT license | 0.9.2beta | 09/02/2007 |
| 0.9.1beta | MIT license | 0.9.1beta | 08/02/2007 |
| 0.9.0beta | MIT license | 0.9.0beta | 08/02/2007 |
sfCurlAdaptersfCurlAdaptersfCurlAdapter (based on a patch by adoanhuu)getResponseXMLsfCurlAdaptersfCurlAdapter: Added new options: 'cookies', 'cookies_dir', 'cookies_file', 'verbose', 'verbose_log'sfCurlAdapter: Increased speed by Moving some initialization from call() to the constructersfFopenAdapter error handlersfSocketsAdaptersfSocketsAdapterThe sfWebBrowserPlugin proposes an HTTP client capable of making web requests. The interface is similar to that of sfTestBrowser.
This plugin contains one single class: sfWebBrowser. Unit tests are available in the SVN repository, to be placed in a symfony application's test/ directory.
The sfWebBrowser class makes web requests based on a URI:
$b = new sfWebBrowser();
$b->get('http://www.example.com/');
$res = $b->getResponseText();
The usual methods of the sfTestBrowser also work there, with the fluid interface.
// Inline
$b->get('http://www.example.com/')->get('http://www.google.com/')->back()->reload();
// More readable
$b->get('http://www.example.com/')
*>get('http://www.google.com/')
*>back()
*>reload();
The browser accepts absolute and relative URIs
$b->get('http://www.example.com/test.html');
$b->get('test.html');
The get() method accepts parameters either as a query string, or as an array.
$b->get('http://www.example.com/test.php?foo=bar');
$b->get('http://www.example.com/test.php', array('foo', 'bar'));
Requests in POST mode are also supported.
$b->post('http://www.example.com/test.php', array('foo', 'bar'));
You can access the response in various formats, at your convenience:
$myString = $b->getResponseText();
$myString = $b->getResponseBody(); // drop the <head> part
$myDomDocument = $b->getResponseDom();
$myDomCssSelector = $b->getResponseDomCssSelector();
$mySimpleXml = $b->getResponseXml();
You can also interact with the response with the setFields() and click() methods.
$b->get('http://www.example.com/login')
*>setField('user', 'foobar')
*>setField('password', 'barbaz')
*>click('submit');
The browser supports HTTP and HTTPS requests, proxies, redirects, and timeouts.
Install the plugin
$ symfony plugin-install http://plugins.symfony-project.com/sfWebBrowserPlugin
Clear the cache to enable the autoloading to find the new class
$ symfony cc
The web request is made via fopen(), so this will only work if PHP is compiled with sockets support and if allow_url_fopen is defined to true in the php.ini.
Cookies are not handled yet.
Caching is not supported yet.
