Posts Tagged curl

Files to edit for enabling cURL in XAMPP?

Last week I was installing “Magento” on XAMPP . Then I realized that cURL was disabled by default in XAMPP. I changed   “\apache\php\php.ini” and uncommented the line for cURL extension but still not working. Finally I made it working by editing couple of “ini” files. I had listed these ini’s below.

\xampp\apache\bin\php.ini
\xampp\apache\php\php5.ini
\xampp\apache\php\php.ini
\xampp\apache\php\php\php4.ini (to switch PHP version)

To enable cURL you need to uncomment the below line

;extension=php_curl.dll

to

extension=php_curl.dll

, ,

No Comments

eSense Page Implementation Problem

I had a strange error while programming which spoiled lot of my time. I was trying to fetch a content from an URL through cURL .

The content I am trying to fetch was from server Microsoft-IIS/6.0 powered by ASP.NET. The error I am getting was “eSense Page Implementation Problem Error: Disabled Cookies”. I tried different methods like file_get_contents() but still not worked.

Finally I solved the issue by setting user agent for request header. Below is my working code

$url="http://www.dfm.ae/pages/default.aspx?c=2000&q0=ajmanbank";
$ch = curl_init();
$header[]="User-Agent: Mozilla/5.0";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERAGENT, '');
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
echo $response = curl_exec($ch);
curl_close($ch);

Hope this may help someone else :)

,

No Comments