Can't fetch my XenForo site w/ cURL

MikeMpls

Well-known member
Why does this code return a null string for a XenForo site (main forum index)? I've tried it with several of my XenForo sites, works fine w/ sites handled by HTML, PERL & other PHP scripts.

It displays "0", not "cURL failed".

PHP:
<?php
// create a new cURL resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://my xenforo site");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);

$data = curl_exec($ch);
curl_close($ch);
if ($data === false)
{
  echo 'cURL failed';
  exit;
}
echo strlen($data);
?>
 
I just tested the code and it works for my site. Send me a PC with your URL and I'll try it on your site.
 
I got it to work by passing the full path of the ".../index.php" file.

Strangely, I did not have to do that with sites whose default directory index was a HTML or PERL file.

So it's still a curiosity as to why this distinction exists.
 
Top Bottom