ascentuk Posted February 1, 2008 Share Posted February 1, 2008 hi im looking for some help im instaling a phpbb forum for my radio station site http://radio.audioaddictz.co.uk im useing streamerp2p to broadcast there is a way i can reqest information from streamerp2p in the form of xml like this in browser http://address:port/xml/stats.xml?password=******* this returns a page like this - <info> - <status> <code>200</code> <message>OK</message> </status> - <station> <name>-= Audio Addictz Psy Trance -=- From Chill Out to Twisted =-</name> <description>no description</description> <active>yes</active> <bitrate>85</bitrate> <format>ogg</format> <viewers>5</viewers> <viewers_high>5</viewers_high> </station> </info> i would like to be able to display certain bits of that info in my phpbb forum portal the information i would like to display is the values for active, bitrate , format and viewers im planing to use ezportal on the phpbb forum and would like to display the info in a portal block the problem is whilst im capable of installing phpbb and adding mods im no php coder if anyone can point me in the right direction that would be fantastic thanks in advance for any help Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/ Share on other sites More sharing options...
trq Posted February 1, 2008 Share Posted February 1, 2008 Take a look at the simplexml extension. Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-455691 Share on other sites More sharing options...
ascentuk Posted February 2, 2008 Author Share Posted February 2, 2008 Wow thanks for the quick reply will check it out now tip top Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-455730 Share on other sites More sharing options...
ascentuk Posted February 2, 2008 Author Share Posted February 2, 2008 sorry for being such a noob , but i think im gonna need some more help with this ive taken a look at the link you sent but ive no idea which example i need to use if you could sugest a example i should be useing to display the info i need Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-455749 Share on other sites More sharing options...
ascentuk Posted February 2, 2008 Author Share Posted February 2, 2008 this is what myself and a friend have tried so far and i just get an error opening the xml <?php if (file_exists('http://address:port/xml/stats.xml?password=********')) { $xml = simplexml_load_file('http://address:port/xml/stats.xml?password=*******'); var_dump($xml); } else {exit('Error loading /xml/stats.xml.');} ?> obviously i replaced where i put address:port and password for security reasons but you get the idea Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-455780 Share on other sites More sharing options...
trq Posted February 2, 2008 Share Posted February 2, 2008 You might want to load the xml into a local variable firstly. <?php $xml = file_get_contents('http://address:port/xml/stats.xml?password=********'); $xmlobj = simplexml_load_string($xml); var-dump($xmlobj); ?> Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-455817 Share on other sites More sharing options...
ascentuk Posted February 2, 2008 Author Share Posted February 2, 2008 ok i altered my code to this <?php $xml = file_get_contents('http://address:port/xml/stats.xml?password=********'); $xmlobj = simplexml_load_string($xml); var-dump($xmlobj); else {exit('Error loading /xml/stats.xml.');} ?> i dont get any errors now so i presume its now loading the xml correctly my next problem is how do i get it to display various bits of information from the xml thanks for your help so far , its begining to make some sence to me now hehe Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456089 Share on other sites More sharing options...
ascentuk Posted February 2, 2008 Author Share Posted February 2, 2008 Ive tried some other stuff but still geting nothing to display <?php $xml = file_get_contents('http://address:port/xml/stats.xml?password=*********'); $xmlobj = simplexml_load_string($xml); var-dump($xmlobj); echo $xml->info[0]->active; echo $xml->info[0]->bitrate; echo $xml->info[0]->format; echo $xml->info[0]->viewers; else {exit('Error loading /xml/stats.xml.');} ?> i would realy apreciate any help im proberbly making a typical noob mistake thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456150 Share on other sites More sharing options...
ascentuk Posted February 2, 2008 Author Share Posted February 2, 2008 this maybe a stupid question but is The SimpleXML extension something i need to download and install at my webhost or is it a command built into php5 im just wondering because the code ive writern looks to me like it should work but im getting no results Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456320 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 A few things. its var_dump() not var-dump(). Hence thats not outputting anything. Next, the simplexml object is called $xmlobj not $xml. $xml is simply the string containing your xml. Thirdly, you have an else statement with no if. Turn on errror reporting to let you see any errors you may be producing. Try... <?php // error reporting. error_reporting(E_ALL) ; ini_set('display_errors','1'); $xml = file_get_contents('http://address:port/xml/stats.xml?password=*********'); $xmlobj = simplexml_load_string($xml); var_dump($xmlobj); echo $xmlobj->info[0]->active; echo $xmlobj->info[0]->bitrate; echo $xmlobj->info[0]->format; echo $xmlobj->info[0]->viewers; ?> Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456438 Share on other sites More sharing options...
ascentuk Posted February 3, 2008 Author Share Posted February 3, 2008 ok tried that and now i get the following error Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in C:\domains\ascentwd.co.uk\wwwroot\info.php on line 6 Warning: file_get_contents(http://address:port/xml/stats.xml?password=**********) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in C:\domains\ascentwd.co.uk\wwwroot\info.php on line 6 Fatal error: Call to undefined function: simplexml_load_string() in C:\domains\ascentwd.co.uk\wwwroot\info.php on line 7 dunno if it makes any diffrence , but my hosting is on windows servers Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456443 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 Looks like allow_url_fopen is disabled in your install. What is the output of.... <?php if (ini_get('allow_url_fopen')) { echo "allow url fopen enabled"; } else { echo "allow url fopen disabled"; } ?> Without this you cannot access remote files. Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456445 Share on other sites More sharing options...
ascentuk Posted February 3, 2008 Author Share Posted February 3, 2008 allow url fopen disabled yip looks like its disabled then is that something my hosting provider can change for me ??? if not i run an appache server on my network at the studio , it has php5 and sql installed also do you think i might have more change of running it on my local server either way i dont mind as long as i can get it working thanks for your quick reply Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456451 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 Your hosting provider will likely not enable it for you, but there is no harm in asking. As for running it on your local server, your in charge, so can do what you like. To enable it, open your php.ini file, find the line with allow_url_fopen on it and change it to On. It is on by default. If you have made any changes to the ini file you will need to restart the server. Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456454 Share on other sites More sharing options...
ascentuk Posted February 3, 2008 Author Share Posted February 3, 2008 Fantastic i will try it on my server at the studio monday will let you know how it goes many thanks for all your help so far Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-456457 Share on other sites More sharing options...
Innah Posted February 4, 2008 Share Posted February 4, 2008 good evenings , i gave it a try using the code made a php file using this: <?php // error reporting. error_reporting(E_ALL) ; ini_set('display_errors','1'); $xml = file_get_contents('http://localhost:port/xml/stats.xml?password=******'); $xmlobj = simplexml_load_string($xml); var_dump($xmlobj); echo $xmlobj->info[0]->active; echo $xmlobj->info[0]->bitrate; echo $xmlobj->info[0]->format; echo $xmlobj->info[0]->viewers; ?> this is the output i see in firefox: object(SimpleXMLElement)#1 (2) { ["status"]=> object(SimpleXMLElement)#2 (2) { ["code"]=> string(3) "200" ["message"]=> string(2) "OK" } ["station"]=> object(SimpleXMLElement)#3 (7) { ["name"]=> string(12) "Inner Wisdom" ["description"]=> string(14) "no description" ["active"]=> string(3) "yes" ["bitrate"]=> string(2) "35" ["format"]=> string(3) "aac" ["viewers"]=> string(1) "0" ["viewers_high"]=> string(1) "0" } } Notice: Trying to get property of non-object in C:\wosportable\www\stats.php on line 10 Notice: Trying to get property of non-object in C:\wosportable\www\stats.php on line 11 Notice: Trying to get property of non-object in C:\wosportable\www\stats.php on line 12 Notice: Trying to get property of non-object in C:\wosportable\www\stats.php on line 13 this ok or not ???? how you progressing sofar Ascender ? Quote Link to comment https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/#findComment-457816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.