I just want to make a httprequest with post parameters. I used this code
$r = new HttpRequest($url, HttpRequest::METH_POST);
$r->send();
but I get this error:
ErrorException [ Fatal Error ]: Class 'HttpRequest' not
I added extension=php_http.dll
this to my php.ini, but the problem still exists.
I download the php_http.dll file and inserted it in the ext folder of php but it was already existing so I replaced and still have the same problem.
Any help would be appreciated
If you are using php 5.4 or above, there does not seem to be a php_http.dll file to include in your extensions library (Unless someone can find one that I missed??).
The only one that I could find generated errors on starting up the Apache server after updating the php.ini configuration file to include the extension.
Fear not however, as there seems to be a GitHub Project which provides the functionality within a class, rather than an extension. Click here to find the required class.
If you save this class in your project and call like so;
Failing that, it would seem that the only other viable option would be to compile the .dll yourself from the source here :(
Otherwise, another option would be to use cURL instead. cURL provides most (if not all) of the functionality of the
httpRequest
.A simple example of this would be;
More details and better examples can be found on the php website Here
I hope this helps answer your question, rather than leave you with more...
You need to make sure you have a
php_http.dll
that matches your PHP version. You can do<?php phpinfo();
to check with extensions are loaded (look for "http", it will list the version and available classes).If the extension does not appear in
phpinfo()
, you should check your logs to learn where the problem comes from or run the PHP binary directly from the command prompt —php -i
. If there is any error loading a dynamic library it will show up in a dialog box. Note that PHP will still continue to function even though an extension failed to load.you can reinstall the package
or access the data using curl like this snippet