Not working HTTPS queries with Curl

If you can work with usual http queries using PHP Curl, but have problems with https you can try to include this option:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

Tuesday, July 22nd, 2008

URL file-access problems in PHP

For many hosting providers it’s standart to disable URL file access. So, if your PHP code has file_get_contents(), require(), require_once(), include() or include_once() commands with some URL as a parameter, you will receive an error message: ‘URL file-access is disabled in the server configuration’.

To avoid this error you can try to use CURL.

Instead of this command:

$content = file_get_contents('http://sample_url');

You should use:

$ch = curl_init();
$timeout = 3;
curl_setopt ($ch, CURLOPT_URL, 'http://sample_url');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$content = curl_exec($ch);

Sunday, March 30th, 2008