0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

ok, the result was connect() timed out. Would increasing the curlopt_connecttimeout resolve this?
after increasing the connecttimeout to 45, I now get a couldn't connect to host error.
Perhaps wowarmory.com needs more headers, like Accept, Accept-Language and so on.
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.
Try adding a header at the end like: header('Content-type: application/xml');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.