Skip to content

Commit 25ff27a

Browse files
2 parents 0cc9ba8 + b17f219 commit 25ff27a

File tree

5 files changed

+73
-75
lines changed

5 files changed

+73
-75
lines changed

app/Http/Controllers/LastFmController.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Buzz\Browser;
88
use App\Http\Requests;
99
use App\Http\Controllers\Controller;
10-
use MetalMatze\LastFm\LastFm;
10+
use Dandelionmood\LastFm\LastFm;
1111

1212
class LastFmController extends Controller
1313
{
@@ -22,12 +22,11 @@ class LastFmController extends Controller
2222
*/
2323
public function __construct()
2424
{
25-
$this->lastfm = new LastFm(new Browser);
26-
$this->lastfm->setApiKey(env('LASTFM_API_KEY'));
25+
$this->lastfm = new LastFm(env('LASTFM_API_KEY'), env('LASTFM_API_SECRET'));
2726
}
2827

2928
/**
30-
* Return all tweets to the Twitter API dashboard
29+
* Return all tweets to the LastFM API dashboard
3130
* @return mixed
3231
*/
3332
public function getPage()
@@ -49,7 +48,7 @@ public function getPage()
4948
*/
5049
private function getArtistInfo()
5150
{
52-
$result = json_decode($this->lastfm->artist_getInfo(['artist' => 'The Pierces']), true);
51+
$result = (array)$this->lastfm->artist_getInfo(['artist' => 'The Pierces']);
5352

5453
return $result['artist'];
5554
}
@@ -60,9 +59,9 @@ private function getArtistInfo()
6059
*/
6160
private function getTopAlbums()
6261
{
63-
$result = json_decode($this->lastfm->artist_getTopAlbums(['artist' => 'The Pierces']), true);
62+
$result = (array)$this->lastfm->artist_getTopAlbums(['artist' => 'The Pierces']);
6463

65-
return $result['topalbums']['album'];
64+
return $result['topalbums']->album;
6665
}
6766

6867
/**
@@ -71,8 +70,8 @@ private function getTopAlbums()
7170
*/
7271
private function getTopTracks()
7372
{
74-
$result = json_decode($this->lastfm->artist_getTopTracks(['artist' => 'The Pierces']), true);
73+
$result = (array)$this->lastfm->artist_getTopTracks(['artist' => 'The Pierces']);
7574

76-
return $result['toptracks']['track'];
75+
return $result['toptracks']->track;
7776
}
7877
}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"jrm2k6/cloudder": "^0.2.2",
1414
"graham-campbell/github": "^4.2",
1515
"thujohn/twitter": "^2.1",
16-
"metalmatze/lastfm-api-wrapper": "dev-master",
1716
"aloha/twilio": "^2.0",
1817
"fabpot/goutte": "^3.1",
1918
"mjerwin/clockwork-sms": "^0.9.1",
@@ -23,7 +22,8 @@
2322
"linkedinapi/linkedin": "^1.1",
2423
"socialiteproviders/foursquare": "^1.1",
2524
"hownowstephen/php-foursquare": "1.2.*",
26-
"jaapz/tumblr": "dev-master"
25+
"jaapz/tumblr": "dev-master",
26+
"dandelionmood/lastfm": "^0.6.0"
2727
},
2828
"require-dev": {
2929
"fzaninotto/faker": "~1.4",

composer.lock

Lines changed: 53 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ Recommended Laravel Libraries
393393
FAQ
394394
---
395395

396-
### Why do I get `Token Mismatch Exceptiom` when submitting a form?
396+
### Why do I get `Token Mismatch Exception` when submitting a form?
397397
You need to add the following hidden input element to your form. This has been
398398
added in the existing codebase as part of the CSRF protection.
399399

@@ -637,4 +637,4 @@ Prosper Otemuyiwa.
637637

638638
## License
639639

640-
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
640+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

resources/views/api/lastfm.blade.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@
1919

2020
<br>
2121

22-
<h3> {{ $details['name'] }}</h3>
22+
<h3> {{ $details->name }}</h3>
2323

2424
<img src="http://img2-ak.lst.fm/i/u/arQ/548cf8296e0e446bc4193a5b5a94bfb7.png" class="thumbnail">
2525

2626
<h3> Tags </h3>
2727

28-
@foreach ($details['tags']['tag'] as $tag)
29-
<span class="label label-primary"><i class="fa fa-tag"></i> {{ $tag['name']}}</span>
28+
@foreach ($details->tags->tag as $tag)
29+
<span class="label label-primary"><i class="fa fa-tag"></i> {{ $tag->name }}</span>
3030
@endforeach
3131

3232
<h3> Biography </h3>
33-
<p>{{ $details['bio']['summary'] }}</p>
33+
<p>{{ $details->bio->summary }}</p>
3434

3535
<h3> Top Albums </h3>
3636
@foreach ($albums as $album)
37-
<img src="{{ $album['image'][3]['#text'] }}" width="150" height="150">
37+
<img src="{{ $album->image[3]->{'#text'} }}" width="150" height="150">
3838
@endforeach
3939

4040
<h3> Top Tracks </h3>
4141
<ol>
4242
@foreach ($tracks as $track)
43-
<li><a href="{{ $track['url'] }}">{{ $track['name'] }}</a></li>
43+
<li><a href="{{ $track->url }}">{{ $track->name }}</a></li>
4444
@endforeach
4545
</ol>
4646

4747
<h3> Similar Artists </h3>
4848
<ul class="list-unstyled list-inline">
49-
@foreach ($details['similar']['artist'] as $artist)
50-
<li><a href="{{ $artist['url'] }}">{{ $artist['name'] }}</a></li>
49+
@foreach ($details->similar->artist as $artist)
50+
<li><a href="{{ $artist->url }}">{{ $artist->name }}</a></li>
5151
@endforeach
5252
</ul>
5353

0 commit comments

Comments
 (0)