Skip to Content
It is currently April 17th, 2021, 6:14 pm

All times are UTC - 6 hours [ DST ]

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: December 12th, 2018, 6:31 am 
New User
New User

Joined: December 12th, 2018, 6:17 am
Posts: 1
I created API for using web scripting based logic module and in the config set "On choose song" URL. I return all information with the correct songID field,
but the song didn't play. In the event log I saw "Not found" exception, but I checked that song ID is correct and I can query song data by this song ID in the database. Also, I saw in the sam broadcaster application, in the Deck, song title and album which I returned from my API, but the song didn't play.
Here my XML which I provide for "On choose song" event:
<LOGIC xmlns:xsd="" xmlns:xsi="">
<title>A Graveyard Night</title>
<album>Arisen From The Ashes</album>

Does anyone knows, what I do wrong in this situation?

Reply with quote  
PostPosted: December 14th, 2018, 5:51 pm 
SVS Member
SVS Member

Joined: December 6th, 2004, 9:00 am
Posts: 8170
Location: Cologne (Germany)
Not sure, but there are two things that caught my eye when comparing with the old SAM 4.3.6 web template that still included a sample web logic module:

#1 You pass the XML namespace to the root LOGIC element, that is not there in the original code.
#2 You're missing the <?xml ?> doctype/namespace tag

Also question:
Are you sending the right content-type? SAM expects text/xml. I know application/xml is also pretty common in XMLRPC, but I think SAM/Delphi/whatever Delphi XML library SAM uses is fixed on that one content-type and doctype. Submitting a newer doctype might confuse the hell out of it.


//Do simple SQL query that selects the Least Recently Played song
$link = mysqli_connect("p:localhost","root","root", "SAMDB");
$res = mysqli_query($link, "SELECT * FROM songlist ORDER BY date_played DESC LIMIT 1");
$row = mysqli_fetch_array($res);

//Fill our variables with XML "friendly" data
$songID = htmlspecialchars($row["ID"]);
$artist = htmlspecialchars($row["artist"]);
$title = htmlspecialchars($row["title"]);
$album = htmlspecialchars($row["album"]);
$duration = $row["duration"];

//Fill in our XML response
 $xml = "<?xml version=\"1.0\"?>
("Content-type: text/xml"); 
echo $xml


This code is almost 1:1 copied from weblogic script in this old archive: ...
I adjusted the commands to use mysqli instead of mysql as that's no longer in PHP7 and made it pick a random instead of the least recently played track (because in my library that will always result in one of the sound effects for a very long time as they are significantly underplayed - read: 0 playcount against the rest of my library)

Seems to work just fine for me.

The actual output looks like this:
<?xml version="1.0"?>

This is my config settings:
webscripting-settings.PNG [ 9.69 KiB | Viewed 2119 times ]

And this is how I ran the code:
λ php -S weblogic.choose.php
PHP 7.2.10 Development Server started at Sat Dec 15 00:42:07 2018
Listening on
Document root is C:\Users\benedikt\Desktop
Press Ctrl-C to quit.

Benedikt Bauer - SVS (Spacial Volunteer Support)

Shop for readymade PAL scripts by countrywesterndj - Or get a custom script made by me (or others)

My Project:
Send "Now Playing" from SAM to Twitter and/or Facebook | Sourcecode

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours [ DST ]

Who is online

Users browsing this forum: No registered users and 24 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group