app\models\Song::scrobble PHP Method

scrobble() public method

Scrobble the song using Last.fm service.
public scrobble ( string $timestamp ) : mixed
$timestamp string The UNIX timestamp in which the song started playing.
return mixed
    public function scrobble($timestamp)
    {
        // Don't scrobble the unknown guys. No one knows them.
        if ($this->artist->isUnknown()) {
            return false;
        }
        // If the current user hasn't connected to Last.fm, don't do shit.
        if (!($sessionKey = auth()->user()->lastfm_session_key)) {
            return false;
        }
        return Lastfm::scrobble($this->artist->name, $this->title, $timestamp, $this->album->name === Album::UNKNOWN_NAME ? '' : $this->album->name, $sessionKey);
    }

Usage Example

Esempio n. 1
0
 /**
  * Scrobble a song.
  *
  * @param Song   $song
  * @param string $timestamp The UNIX timestamp when the song started playing.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function scrobble(Song $song, $timestamp)
 {
     return response()->json($song->scrobble($timestamp));
 }