When using cURL to access a file, it is ignoring the set headers in the said file. When I access the same file directly through the browser without cURL, its works and the headers are set correctly. Anyone know why this is and how I get round this?
I am writing an API and need to set HTTP header responses in web service and not in file used to connect to the file via cURL. Hope that makes sense.
Many thanks in advance.
As You are using CURL, try this as your useragent
curl_setopt($c_link, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)");
or
curl_setopt($c_link, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
You can also copy headers from firefox which might look like this
$header = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header = "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header = "Cache-Control: max-age=0";
$header = "Connection: keep-alive";
$header = "Keep-Alive: 300";
$header = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header = "Accept-Language: en-us,en;q=0.5";
$header = "Pragma: ";
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