1

I am working on a website for a radiostation. I can get the tracks that are playing at the moment from the following code:

<span data-widget="mcp-custom-text" data-name="NAMEOFSTATION" data-format="%nowplaying%"></span></b>

<script type="text/javascript" language="javascript" src="https://NAMESERVER.nl:2020/dist/widgets.js" defer></script>

And I got a radioplayer which shows the text that you want in it, the following code is the part where it displays the text that you want to show in the player:

            $the_link=trim($_GET['the_stream']);
    $t = new streaminfo($the_link);
    $songtitle=strip_tags($t->streamtitle);
    if (trim($songtitle)=='' || trim($songtitle)=='-') {
                $songtitle="SHOW HERE SONGTITLE";
        }
    echo trim($songtitle);
}

?>

How can I get the data of the first code on the position in the player? Because just paste the HTML code in the PHP variable doesn't work.

Pierre Arlaud
  • 4,040
  • 3
  • 28
  • 42
Dennis
  • 53
  • 3

1 Answers1

1

Have you tried using HTTP client to make request to that URL? Looks like you are trying to get data from an API then display it on the screen. If so, try playing around with HTTP client, axios and such

Huy Phạm
  • 888
  • 9
  • 24
  • My knowledge of PHP etc. is just very small. I know a lot of HTML/CSS but not from PHP so what do I have to do for a HTTP client? – Dennis Jul 23 '21 at 07:56
  • The material you given might not suffient for me to answer that. Typically, the radio station provides an URL which is an API, so when a authenticated device connect or access the URL, it will get a response from the server containing currently playing track (name, author, etc), it's hidden somewhere in the HTML or script file. If it's your case, this thread may solve your problem: https://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php – Huy Phạm Jul 23 '21 at 08:19
  • The first script is displaying a realtime songtitle, the only thing i want is to put that title in the PHP-code on the position where now "SHOW HERE SONGTITLE" is written. :) – Dennis Jul 23 '21 at 08:44