Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] Internetowe radio
Forum PHP.pl > Forum > Przedszkole
The Night Shadow
W jaki sposób za pomocą php lub innych jeżyków wyciągnąć informacje o aktualnie granym utworze w danej stacji radiowej?
hwao
Tak, da rady.
Robi sie to przy pomocy funkcji fsockopen" title="Zobacz w manualu php" target="_manual
The Night Shadow
Mam takie radio http://shout24.net:6969/listen.pls

Dla tego skryptu:

  1. <? 
  2. class ShoutCAST { 
  3. var $host, $port, $pass, $dane, $values, $indexes;
  4.  
  5.  
  6. function connect() {
  7. $fp = fsockopen($this->host, $this->port, $errno, $errstr, 10); 
  8. if (!$fp) { return false; 
  9. } else { 
  10. fputs($fp, "GET /admin.cgi?pass=".$this->pass."&mode=viewxml HTTP/1.0rn"); 
  11. fputs($fp, "User-Agent: Mozillarnrn"); 
  12. while (!feof($fp)) { 
  13. $this->dane .= fgets($fp, 512); 
  14. } 
  15. fclose($fp); 
  16. if (stristr($this->dane, "HTTP/1.0 200 OK") != true) return false; 
  17. $code_xml = xml_parser_create(); 
  18. if (!xml_parse_into_struct($code_xml, $this->dane, $this->values, $this->indexes)) return false; 
  19. xml_parser_free($code_xml); 
  20. return true; 
  21. } 
  22. }
  23.  
  24. function showValue($which) { 
  25. return($this->values[$this->indexes[$which][0]]["value"]); 
  26. }
  27.  
  28. } 
  29.  
  30.  
  31.  
  32.  
  33.  
  34. $shoutcast = new ShoutCAST(); 
  35. $shoutcast->host = 'http://shout24.net'; // adres IP serwera 
  36. $shoutcast->port = '6969'; // port serwera 
  37. $shoutcast->passwd = 'haslo'; // hasło do serwera
  38.  
  39.  
  40. if ($shoutcast->connect()) { 
  41. if ($shoutcast->showValue('STREAMSTATUS')) { 
  42. print 'Nazwa serwera:'.$shoutcast->showValue('SERVERTITLE').'<br>'; 
  43. print 'Ilość słuchaczy:'.$shoutcast->showValue('CURRENTLISTENERS').'<br>'; 
  44. print 'Limit słuchaczy:'.$shoutcast->showValue('MAXLISTENERS').'<br>'; 
  45. print 'Rekord słuchaczy:'.$shoutcast->showValue('PEAKLISTENERS').'<br>'; 
  46. print 'Rodzaj serwera:'.$shoutcast->showValue('SERVERGENRE').'<br>'; 
  47. print 'URL serwera:'.$shoutcast->showValue('SERVERURL').'<br>'; 
  48. print 'Nazwa piosenki:'.$shoutcast->showValue('SONGTITLE').'<br>'; 
  49. print 'Jakość nadawania:'.$shoutcast->showValue('BITRATE').'<br>'; 
  50. print 'IRC:'.$shoutcast->showValue('IRC').'<br>'; 
  51. print 'AIM:'.$shoutcast->showValue('AIM').'<br>'; 
  52. print 'ICQ:'.$shoutcast->showValue('ICQ').'<br>';
  53.  
  54.  
  55. } else { 
  56. print "Serwer jest włączony, ale aktualnie nie ma żadnej audycji."; 
  57. }
  58.  
  59. } else { 
  60. print 'Serwer jest wyłączony.'; 
  61. } 
  62. ?>



Pojawia się taki błąd:
Warning: fsockopen() [function.fsockopen]: unable to connect to http://shout24.net:6969 (Unable to find the socket transport "http" - did you forget to enable it when you configured php?) in /home/ogien/public_html/poprosturadio/radio.php5 on line 7
Serwer jest wyłączony.

Co to oznacza? A konkretniej jak wobec tego dostać się do nformacji serwera shoutcast?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.