tags:

views:

315

answers:

1

I'm trying to get character data from www.wowarmory.com using PHP and cURL.

The code I have so far is:

...        
$browser = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";

$url = "http://www.wowarmory.com/character-sheet.xml?r=Ner'zhul&n=Visar";

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt ($ch, CURLOPT_USERAGENT, $browser);

$result = curl_exec($ch);

The var_dump($result) is false, and if I try to parse the $result into an XML the $result is blank.

What I'm trying to get is a characters XML file. (http://www.wowarmory.com/character-sheet.xml?r=Ner%27zhul&n=Visar), but without the XSL attached. Then parse this, and extract info from the file, but I just need to get the file first.

+1  A: 

Call:

echo curl_error($ch);

after the curl_exec to see what the error is since curl_exec is returning false, which indicates an error.

drudru
ok, the result was connect() timed out. Would increasing the curlopt_connecttimeout resolve this?
MJ
after increasing the connecttimeout to 45, I now get a couldn't connect to host error.
MJ
Perhaps wowarmory.com needs more headers, like `Accept`, `Accept-Language` and so on.
Boldewyn
do you have a shell on the box you are running the scripts from? Try doing a command line curl request to see if maybe they are blocking your request.
drudru