When I use this code:
$ch = curl_init($url); $statuses = curl_exec($ch); curl_close($ch);
I am returned what I want, but if I just use that - $statuses
is echoed out onto the page.
How can I stop this?
The curl command with the -o /dev/null option can be used to suppress the response body output. Something like this should be displayed. If you also want to supress the progress bar, the -s or --silent flag can be used. Now the curl command returns no output.
CURLOPT_RETURNTRANSFER: Converts output to a string rather than directly to the screen.
Servers cannot block cURL requests per se, but they can block any request that they do not like. If the server checks for some parameters that your cURL request does not satisfy, it could decide to respond differently.
cURL is a PHP extension that allows you to use the URL syntax to receive and submit data. cURL makes it simple to connect between various websites and domains. Obtaining a copy of a website's material.
Put this on line 2:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Include this option before curl_exec()
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
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