Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/88977-getting-information-from-an-xml-file/
Share on other sites

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

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

 

 

 

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

 

 

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

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

 

 

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;

?>

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

 

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.

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

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.

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 ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.