Last FM Submissions class
Possible Methods
__construct
Default constructor
Parameters
- apiKey string
- A Last.fm API key.
- secret string
- A Last.fm secret
- user string
- Is the name of the user on who's behalf the request is being performed.
- sessionKey string
- The Web Services session key generated via the authentication protocol.
- clientId string
- Is an identifier for the client (See http://www.last.fm/api/submissions#1.1).
- clientVersion string
- Is the version of the client being used.
Return
void
Example
<?php
// require
require_once 'last_fm_submissions.php';
// create instance
$lastfm = new LastFmSubmissions('<your-api-key>', '<your-secret>', '<your-username>', '<your-session-key>', '<client-identifier>', '<client-version>');
?>
setTimeOut
Set the timeout
Parameters
- seconds int
Return
void
setUserAgent
Set the user-agent for you application
It will be appended to ours
Parameters
- useragent
Return
void
submitNowPlaying
Optional lightweight notification of now-playing data at the start of the track for realtime information purposes.
The Now-Playing notification is a lightweight mechanism for notifying Last.fm that a track has started playing. This is used for realtime display of a user's currently playing track, and does not affect a user's musical profile.
The Now-Playing notification is optional, but recommended and should be sent once when a user starts listening to a song.
Parameters
- artist string
- The artist name.
- track string
- The track name.
- album string (optional)
- The album title.
- length int (optional)
- The length of the track in seconds.
- trackNumber string (optional)
- The position of the track on the album.
- mbid string (optional)
- The MusicBrainz Track ID.
Return
void
Example
<?php
// require
require_once 'last_fm_submissions.php';
// create instance
$lastfm = new LastFmSubmissions('<your-api-key>', '<your-secret>', '<your-username>', '<your-session-key>', '<client-identifier>', '<client-version>');
// submit a song
$lastfm->submitNowPlaying('Therion', 'Lemuria', 'Lemuria', 255);
?>
submit
Submission of full track data at the end of the track for statistical purposes.
The client should monitor the user's interaction with the music playing service to whatever extent the service allows. In order to qualify for submission all of the following criteria must be met:
1. The track must be submitted once it has finished playing. Whether it has finished playing naturally or has been manually stopped by the user is irrelevant.
2. The track must have been played for a duration of at least 240 seconds or half the track's total length, whichever comes first. Skipping or pausing the track is irrelevant as long as the appropriate amount has been played.
3. The total playback time for the track must be more than 30 seconds. Do not submit tracks shorter than this.
4. Unless the client has been specially configured, it should not attempt to interpret filename information to obtain metadata instead of using tags (ID3, etc).
Parameters
- artist string
- The artist name.
- track string
- The track title.
- time int
- The time the track started playing, in UNIX timestamp format. This must be in the UTC time zone, and is required.
- length int (optional)
- The length of the track in seconds. Required when the source is P, optional otherwise.
- source string (optional)
- The source of the track, possible values are: P = Chosen by the user (the most common value, unless you have a reason for choosing otherwise, use this), R = Non-personalised broadcast (e.g. Shoutcast, BBC Radio 1), E = Personalised recommendation except Last.fm (e.g. Pandora, Launchcast), L = Last.fm (any mode). In this case, the 5-digit Last.fm recommendation key must be appended to this source ID to prove the validity of the submission (for example, "o[0]=L1b48a").
- rating string (optional)
- A single character denoting the rating of the track, possible values are: L = Love (on any mode if the user has manually loved the track). This implies a listen, B = Ban (only if source=L). This implies a skip, and the client should skip to the next track when a ban happens, S = Skip (only if source=L).
- album string (optional)
- The album title.
- trackNumber string (optional)
- The position of the track on the album.
- mbid string (optional)
- The MusicBrainz Track ID
Return
void
Example
<?php
// require
require_once 'last_fm_submissions.php';
// create instance
$lastfm = new LastFmSubmissions('<your-api-key>', '<your-secret>', '<your-username>', '<your-session-key>', '<client-identifier>', '<client-version>');
// submit a song
$lastfm->submit('Therion', 'Lemuria', 240, 255);
?>