getSessionKey() public method

Get Last.fm's session key for the authenticated user using a token.
public getSessionKey ( string $token ) : string
$token string The token after successfully connecting to Last.fm
return string The token key
Example #1
0
 /**
  * Serve the callback request from Last.fm.
  *
  * @param Request $request
  * @param Lastfm  $lastfm
  *
  * @return \Illuminate\Http\Response
  */
 public function callback(Request $request, Lastfm $lastfm)
 {
     abort_unless($token = $request->input('token'), 500, 'Something wrong happened.');
     // Get the session key using the obtained token.
     abort_unless($sessionKey = $lastfm->getSessionKey($token), 500, 'Invalid token key.');
     $this->auth->user()->savePreference('lastfm_session_key', $sessionKey);
     return view('api.lastfm.callback');
 }
 public function testGetSessionKey()
 {
     $client = m::mock(Client::class, ['get' => new Response(200, [], file_get_contents(dirname(__FILE__) . '/blobs/lastfm/session-key.xml'))]);
     $api = new Lastfm(null, null, $client);
     $this->assertEquals('foo', $api->getSessionKey('bar'));
 }