Skip to Content
It is currently March 5th, 2021, 7:55 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: December 12th, 2018, 6:31 am 
Offline
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:
Code:
<LOGIC xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<song>
<songID>3789</songID>
<artist>Ondskapt</artist>
<title>A Graveyard Night</title>
<album>Arisen From The Ashes</album>
<duration>307513</duration>
</song>
</LOGIC>

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


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

Joined: December 6th, 2004, 9:00 am
Posts: 8156
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.


Code:

<?php
 
//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\"?>
<LOGIC>
   <song>
     <songID>
$songID</songID>
     <artist>
$artist</artist>
     <title>
$title</title>
     <album>
$album</album>
     <duration>
$duration</duration>
   </song>
</LOGIC>"
;
 
header
("Content-type: text/xml"); 
echo $xml
;

?>


This code is almost 1:1 copied from weblogic script in this old archive: http://support.spacialaudio.com/wiki/Im ... ebv436.zip
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:
Code:
<?xml version="1.0"?>
<LOGIC>
   <song>
     <songID>10</songID>
     <artist></artist>
     <title>Applause</title>
     <album></album>
     <duration>9535</duration>
   </song>
</LOGIC>


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


And this is how I ran the code:
Code:
λ php -S 0.0.0.0:8000 weblogic.choose.php
PHP 7.2.10 Development Server started at Sat Dec 15 00:42:07 2018
Listening on http://0.0.0.0:8000
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


Top
 Profile  
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 31 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:  
cron
Powered by phpBB® Forum Software © phpBB Group