I tried to make cross domain request in php coding using http_get. In my server, there is no required modules installed. I dont know what to install to make posible of doing http_get.
The error which i got was
Fatal error: Call to undefined function http_get() in C:\xampp\htdocs\article\index.php on line 2
I tried to do so (PECL pecl_http >= 0.1.0) http_get — Perform GET request
but, i did not find out solution.
So, please help me to run http_get coding. Thanks in advance.
I think that you have to enable extension=php_http.dll
in your php.ini
file and after that restart your Apache Server.
I advise you to use cURL instead of http_get()
(same manipulation, you have to enable extension=php_curl.dll
and restart apache)
Hope that Helps :)
To directly answer the question, you've to enable extension=php_http.dll
in php.ini
and restart apache, but there's absolutely no need to use http_get()
in our days.
Here's 3 good alternatives:
Curl
usage:
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://testcURL.com/?item1=value&item2=value2',
CURLOPT_USERAGENT => 'User Agent X'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
file_get_content()
usage:
$my_var = file_get_contents("https://site/");
copy()
usage:
copy("https://site/image.png", "/local/image.png");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With