Page 1 of 1
Fetch Data,statistic from another server/database
Posted: Wed Mar 31, 2010 10:13 am
by jonkelew
hi
i found it very hard to do this (title says all) i got a site where it suppose to be a php script but i cant seem to use it...
http://xml.heroesofnewerth.com/
Re: Fetch Data,statistic from another server/database
Posted: Wed Mar 31, 2010 11:10 am
by Weiry
This script requires you to have the 'curl' extension enabled on your apache web server.
Code: Select all
function loadXML($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
$xmlData = loadXML('yoururl');
$heroName = $xmlData->hero_usage[0]->stat[0];
//where "hero_usage[x]" would be your first XML entry (x = 0,1,2,3,4,etc)
//ie. hero_usage[0] would be:
//<hero_usage hid='2'>
// <stat name='cli_name'>Hero_Armadon</stat>
// <stat name='used'>33933</stat>
//</hero_usage>
Don't quote me on everything though.. im still newish to working with xml
You should really check out tutorials on how to use XMl inside php
W3Schools as a basic example
Re: Fetch Data,statistic from another server/database
Posted: Wed Mar 31, 2010 12:48 pm
by jonkelew
ye i have read basic xml but never seen about xml in php... anyway thanks for the php script
edit: on $xmlData = loadXML('yoururl');... i am supposed to put "
http://xml.heroesofnewerth.com/xml_requester.php" in there?
Re: Fetch Data,statistic from another server/database
Posted: Wed Mar 31, 2010 1:02 pm
by jonkelew
how do i know if i got 'curl' extension??
EDIT: well it seems i dont got it...
Fatal error: Call to undefined function curl_init() in /home/vg5/public_html/honfetch.php on line 4
Re: Fetch Data,statistic from another server/database
Posted: Wed Mar 31, 2010 3:17 pm
by jonkelew
btw maybe i was a abit unclear.. the site i linked is not my site... it is the server i want to retrieve the data from to my site