We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit db19c434 authored by Mike Sheldon's avatar Mike Sheldon

Implement track.love web service method

parent ca1b4660
...@@ -80,6 +80,7 @@ $method_map = array( ...@@ -80,6 +80,7 @@ $method_map = array(
'track.gettoptags' => method_track_getTopTags, 'track.gettoptags' => method_track_getTopTags,
'track.gettags' => method_track_getTags, 'track.gettags' => method_track_getTags,
'track.ban' => method_track_ban, 'track.ban' => method_track_ban,
'track.love' => method_track_love,
); );
function method_user_getrecenttracks() { function method_user_getrecenttracks() {
...@@ -428,6 +429,16 @@ function method_track_ban() { ...@@ -428,6 +429,16 @@ function method_track_ban() {
print(XML::prettyXML(TrackXML::ban($_POST['artist'], $_POST['track'], $userid))); print(XML::prettyXML(TrackXML::ban($_POST['artist'], $_POST['track'], $userid)));
} }
function method_track_love() {
if (!isset($_POST['artist']) || !isset($_POST['track'])) {
report_failure(LFM_INVALID_PARAMS);
}
$userid = get_userid();
header('Content-Type: text/xml');
print(XML::prettyXML(TrackXML::love($_POST['artist'], $_POST['track'], $userid)));
}
function get_userid() { function get_userid() {
global $adodb; global $adodb;
......
...@@ -82,5 +82,20 @@ class TrackXML { ...@@ -82,5 +82,20 @@ class TrackXML {
return $xml; return $xml;
} }
public static function love($artist, $name, $userid) {
global $adodb;
try {
$res = $adodb->Execute("INSERT INTO loved_tracks VALUES ("
. $userid . ", "
. $adodb->qstr($name) . ', '
. $adodb->qstr($artist) . ")");
} catch (exception $ex) {}
$xml = new SimpleXMLElement('<lfm status="ok"></lfm>');
return $xml;
}
} }
?> ?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment