Recently i'm getting a poblem with Last.fm API, I have a fully functional code that worked 2/3 days ago but today each attempt to get artists pics from API returns an array with same url on all image sizes for all artists. A gray background white star image. I've tried to create another account with a new API key to check if it was a problem with my key once there's months since last time i updated the API related code but no succsses.
Here's the code
private static final String BASE_URL = "http://ws.audioscrobbler.com/2.0/";
private static final String API_KEY = "123456789";
@Nullable
public static String fetchJson(String url) {
HttpURLConnection urlConnection = null;
StringBuilder mStringBuilder = new StringBuilder();
try {
urlConnection = (HttpURLConnection) new URL(url).openConnection();
InputStream mInputStream = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader mReader = new BufferedReader(new InputStreamReader(mInputStream));
String line;
while ((line = mReader.readLine()) != null) {
mStringBuilder.append(line);
}
return mStringBuilder.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (urlConnection != null) urlConnection.disconnect();
}
}
public static String createArtistURL(String artistName) {
artistName = artistName.replace("&", "%26");
// TODO: 03/05/2019 testar isso URLEncoder.encode(artistName,UTF?);
return BASE_URL.concat("?method=artist.getinfo")
.concat("&artist=").concat(artistName)
.concat("&lang=").concat(Locale.getDefault().getLanguage())
.concat("&api_key=").concat(API_KEY)
.concat("&format=json");
}