Creating a http request via PHP
Posted: Sun Aug 02, 2009 12:37 am
Hello,
New to PHP and New to the forum here.
Anyway, for my website, I need to make a HTTPRequest to a websiteURL and get the response which will be an XML document (90% of the time).
I looked into the HTTPRequest class but I couldn't get it to work with my code.
echo 'test';
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
echo 'test';
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
This is what I have for my php.ini file....
#Sun Apr 05 14:04:18 IDT 2009
zend_extension=./ZendDebugger.so
extension=php_http.dll
I was told to add extension = php_http.dll to the ini file so I did, but its not working.
As you can see, I have put two "echo 'test';" phrases and the second echo doesn't actually get called so I'm guessing theres something wrong with the
httprequest code (probably not recognizing). I am not familiar with how import/include works with php..... I'm guessing php.ini is doing it ?
Anyway, help will be very much appreciated
New to PHP and New to the forum here.
Anyway, for my website, I need to make a HTTPRequest to a websiteURL and get the response which will be an XML document (90% of the time).
I looked into the HTTPRequest class but I couldn't get it to work with my code.
echo 'test';
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
echo 'test';
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
This is what I have for my php.ini file....
#Sun Apr 05 14:04:18 IDT 2009
zend_extension=./ZendDebugger.so
extension=php_http.dll
I was told to add extension = php_http.dll to the ini file so I did, but its not working.
As you can see, I have put two "echo 'test';" phrases and the second echo doesn't actually get called so I'm guessing theres something wrong with the
httprequest code (probably not recognizing). I am not familiar with how import/include works with php..... I'm guessing php.ini is doing it ?
Anyway, help will be very much appreciated