1
Hello, I have to pull data from a feed using Curl in PHP. Once extracted, I record the result in my bank.
The problem is that the result of the call is giant. Is there any way to control this flow?
This is the code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://site.com/?_restfully=true&fromDate=2017-09-07");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$headers = array();
$headers[] = "Authorization: Bearer $token";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
I think you can use the
CURLOPT_XFERINFOFUNCTION
orCURLOPT_WRITEFUNCTION
, I will test here and if it works I publish here. If you want to abort the connection if the content is too big you have theCURLOPT_MAXFILESIZE
, I think employee.– Inkeliz
the curl_exec function returns which type?
– user45474