2012-06-20 8 views
0

내 안드로이드 응용 프로그램에서 spotify 웹 API를 구문 분석하려고하면 페이지가 404를 반환합니다. URL은 나에게 잘 보이게됩니다. (http://ws.spotify.com/search/ ? 1/album.xml q는 = 앨범 '메테오라'+ 아티스트 :spotify web-api 반환 문의 404

: 여기
 url = new URL("http://ws.spotify.com/search/1/album.xml?q=album:'" + albumName + "'+artist:'" +artistName +"'"); 

     urlc = url.openConnection(); 
     urlc.addRequestProperty("User-Agent", userAgent); 
     Log.v(TAG_SPOTIFY, "User-agent set: " + userAgent); 
     return this.parseSpotifyURI(urlc.getInputStream()); 

오류입니다 : '린킨 파크')는,하지만 여기에

(404) 내 코드 반환

06-20 16:51:00.846: W/System.err(4962): java.io.FileNotFoundException: http://ws.spotify.com/search/1/album.xml?q=album:'Meteora'+artist:'Linkin Park' 
06-20 16:51:00.846: W/System.err(4962):  at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177) 
06-20 16:51:00.846: W/System.err(4962):  at com.micky.scanthings.music.ParseMusic.getSpotifyURI(ParseMusic.java:489) 
... 

답변

1

괜찮습니다. 스포티 파이는 404 솔루션으로 대응 그래서 내 URL이 UTF8로 인코딩되지 않은 것은 앨범 이름과 아티스트를 구문 분석하는 것입니다 그런 식으로 우리가이 URL을 원하는대로 다음

String myURL = "album:'" + albumName + "'+artist:'" +artistName +"'"; 
url = new URL("http://ws.spotify.com/search/1/album.xml?q=" + URLEncoder.encode(myURL,"UTF-8")); 

및 않습니다.