-2

I'm trying to get an artist's number of followers.

If I use the metadata api call

http://ws.spotify.com/lookup/1/?uri=spotify:artist:4YrKBkKSVeqDamzBPWVnSJ

I just get the name of the artist.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
Yohann
  • 265
  • 1
  • 8
  • 17

1 Answers1

3

I'm assuming you want a PHP solution.

Using the spotify-web-api-php library (shameless self promotion) it's really easy. Take a look at this example:

<?php
require_once 'src/Request.php';
require_once 'src/SpotifyWebAPI.php';

$api = new SpotifyWebAPI\SpotifyWebAPI();
$artist = $api->getArtist('0OdUWJ0sBjDrqHygGUXeCF');

echo '<b>Number of followers:</b> ' . $artist->followers->total;

As mentioned earlier, also take a look at the official Spotify docs.

Michael Thelin
  • 4,710
  • 3
  • 23
  • 29
jwilsson
  • 156
  • 1
  • 4
  • Yes that's it ! I wonder if I can get access token without asking user to login (cf. https://developer.spotify.com/web-api/authorization-guide/#authorization-code-flow), without using redirect uri, just using client_id and client_secret. – Yohann Dec 11 '14 at 08:58
  • Take a look at the [Client Credentials Flow](https://developer.spotify.com/web-api/authorization-guide/#client-credentials-flow) and the method for it in [my library](http://jwilsson.github.io/spotify-web-api-php/authorization.html#client-credentials-flow). A value for the redirect uri is currently needed but it can just be an empty string. – jwilsson Dec 11 '14 at 11:55