• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Can't fetch my XenForo site w/ cURL

MikeMpls

Well-known member
#1
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);
?>
 

MikeMpls

Well-known member
#3
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.