http://api.deezer.com/2.0/playlist/4341978から json コンテンツを抽出しようとしていますが、ログに以下のエラー メッセージが出力されます。
エラー: org.json.JSONException: 値 {"エラー":{"メッセージ":"アクティブなアクセス トークンを使用して、現在のユーザーに関する情報を照会する必要があります","タイプ":"OAuthException","コード":200}タイプ org.json.JSONObject の JSONArray に変換できません
ジェイソン
{
"id": 4341978,
"title": "Archive",
"duration": 2063,
"public": true,
"is_loved_track": false,
"collaborative": true,
"rating": 5,
"link": "http://www.deezer.com/playlist/4341978",
"picture": "http://api.deezer.com/2.0/playlist/4341978/image",
"creator": {
"id": 2529
},
"type": "playlist",
"tracks": {
"data": [
{
"id": 1152226,
"readable": true,
"title": "Darkroom",
"link": "http://www.deezer.com/track/1152226",
"duration": 271,
"preview": "http://cdn-preview-6.deezer.com/stream/6452dbcd46c90a70cb1147666ffd91ae-0.mp3",
"artist": {
"id": 1334,
"name": "Archive",
"link": "http://www.deezer.com/artist/1334"
},
"album": {
"id": 123427,
"title": "Londinium",
"cover": "http://api.deezer.com/2.0/album/123427/image"
},
"type": "track"
},
{
"id": 708335,
"readable": false,
"title": "Again",
"link": "http://www.deezer.com/track/708335",
"duration": 980,
"preview": "http://cdn-preview-d.deezer.com/stream/d8fe302b80c2be8a5fed4b8341f1286e-2.mp3",
"artist": {
"id": 1334,
"name": "Archive",
"link": "http://www.deezer.com/artist/1334"
},
"album": {
"id": 84795,
"title": "You All Look The Same To Me (open disc)",
"cover": "http://api.deezer.com/2.0/album/84795/image"
},
"type": "track"
},
{
"id": 778880,
"readable": false,
"title": "Fuck U",
"link": "http://www.deezer.com/track/778880",
"duration": 312,
"preview": "http://cdn-preview-5.deezer.com/stream/505ca648dde07ce1288de4a8762f36e6-2.mp3",
"artist": {
"id": 1334,
"name": "Archive",
"link": "http://www.deezer.com/artist/1334"
},
"album": {
"id": 91316,
"title": "Noise",
"cover": "http://api.deezer.com/2.0/album/91316/image"
},
"type": "track"
},
{
"id": 1965620,
"readable": true,
"title": "Stairway To Heaven",
"link": "http://www.deezer.com/track/1965620",
"duration": 500,
"preview": "http://cdn-preview-3.deezer.com/stream/3a1e4062efacdef98745cc2e05c84b66-1.mp3",
"artist": {
"id": 1548,
"name": "Dweezil Zappa",
"link": "http://www.deezer.com/artist/1548"
},
"album": {
"id": 199616,
"title": "Led Box - The Ultimate Led Zeppelin Tribute",
"cover": "http://api.deezer.com/2.0/album/199616/image"
},
"type": "track"
}
]
}
}
ここに私の非同期タスクがあります
class MyAsyncTask は AsyncTask を拡張します {
private ProgressDialog progressDialog = new ProgressDialog(context);
InputStream inputStream = null;
String result = "";
protected void onPreExecute() {
progressDialog.setMessage("Downloading your data...");
progressDialog.show();
progressDialog.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface arg0) {
MyAsyncTask.this.cancel(true);
}
});
}
@Override
protected Void doInBackground(String... params) {
String url_select = "http://api.deezer.com/2.0/playlist/4341978";
ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();
try {
// Set up HTTP post
// HttpClient is more then less deprecated. Need to change to URLConnection
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url_select);
httpPost.setEntity(new UrlEncodedFormEntity(param));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
// Read content & Log
inputStream = httpEntity.getContent();
} catch (UnsupportedEncodingException e1) {
Log.e("UnsupportedEncodingException", e1.toString());
e1.printStackTrace();
} catch (ClientProtocolException e2) {
Log.e("ClientProtocolException", e2.toString());
e2.printStackTrace();
} catch (IllegalStateException e3) {
Log.e("IllegalStateException", e3.toString());
e3.printStackTrace();
} catch (IOException e4) {
Log.e("IOException", e4.toString());
e4.printStackTrace();
}
// Convert response to string using String Builder
try {
BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"), 8);
StringBuilder sBuilder = new StringBuilder();
String line = null;
while ((line = bReader.readLine()) != null) {
sBuilder.append(line + "\n");
}
inputStream.close();
result = sBuilder.toString();
} catch (Exception e) {
Log.e("StringBuilding & BufferedReader", "Error converting result " + e.toString());
}
return null;
} // protected Void doInBackground(String... params)
protected void onPostExecute(Void v) {
//parse JSON data
try{
JSONArray jArray = new JSONArray(result);
for(int i=0; i < jArray.length(); i++) {
JSONObject jObject = jArray.getJSONObject(i);
String name = jObject.getString("title");
String tab1_text = jObject.getString("type");
int active = jObject.getInt("tracks");
System.out.println("name: "+name+"\n");
System.out.println("tab1_text: "+tab1_text+"\n");
System.out.println("active: "+active+"\n");
} // End Loop
this.progressDialog.dismiss();
} catch (JSONException e) {
Log.e("JSONException", "Error: " + e.toString());
} // catch (JSONException e)
} // protected void onPostExecute(Void v)
} //クラス MyAsyncTask は AsyncTask を拡張します
どうすればこのエラーを解決できますか