Since my old tutorial files are lost I made some new ones.
You can check them out here:
php_ajax_armory_tutorial - rothui - Google Code
Three files are needed.
- A basic PHP file that does the structure and includes links that will call your AJAX function
guild_data.php - rothui - Google Code
armory.js - rothui - Google Code
- Another PHP file that is called by the AJAX function and retrieves the information for you
get_char_data_xml.php - rothui - Google Code
As some posts on page 3 already have mentioned we are now using a class that contains the retrieved information.
If your webserver does not support CURL you can try this function to get the XML string instead. If it does support CURL you should make use of it.
$url_array = parse_url($url);
$fp = fsockopen($url_array['host'], 80, $errno, $errstr, 5);
$send = "GET " . $url_array[path] . "?" . $url_array[query] ." HTTP/1.0\r\n";
$send .= "Host: " . $url_array[host] . " \r\n";
$send .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n";
$send .= "Accept-Language: " . $lang . "\r\n";
$send .= "Connection: Close\r\n\r\n";
while ($fp && !feof($fp))
$headerbuffer = fgets($fp, 1024);
if (urlencode($headerbuffer) == "%0D%0A")
$xml_data = '';
$xml_data .= fgets($fp, 1024);
Remember: If you do not support the Request with a browser information the response will be HTML and not XML always. So if you want an XML response add some kind of user agent information. But sometimes HTML is wanted, tooltips for example.
Oh btw...Don't spam the armory server with requests or you will find yourself banned temporarily shortly after.