0
public static boolean deleteSubscribe(String subscription_id, String authToken){
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost("https://gdata.youtube.com/feeds/api/users/default/subscriptions/"+subscription_id+"?v=2");
    httpPost.setHeader("DELETE", "/feeds/api/users/default/subscriptions/"+subscription_id+" HTTP/1.1"); 
    httpPost.setHeader("Host", "gdata.youtube.com"); 
    httpPost.setHeader("Authorization", "Bearer "+authToken);
    httpPost.setHeader("GData-Version", "2");
    httpPost.setHeader("X-GData-Key", "key="+DeveloperKey.DEVELOPER_KEY);
    HttpResponse httpResponse = null;
    httpPost.setHeader("Content-type","application/atom+xml");

    try {

        httpResponse = httpClient.execute(httpPost);
        BufferedReader reader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent(), "UTF-8"));
        String json = reader.readLine();
        System.out.println("remove:" + json);

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);
}

このコードを使用して、Youtube API でサブスクライブを削除しています。サブスクライブを正常に追加できますが、関数を削除するとエラーが発生しました:

http://schemas.google.com/g/2005'>GDatainvalidRequestUri無効なリクエスト URI

ドキュメントへの元のリンク。

誰でも助けてくれますか?

4

1 に答える 1

1

開発者キー、authtoken、および subscription_id を URL コード化してみてください。

于 2013-03-03T08:19:57.567 に答える