【问题标题】:Android youtube api delete subscription not workingAndroid youtube api删除订阅不起作用
【发布时间】:2013-02-17 11:33:39
【问题描述】:
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'>GDatainvalidRequestUriInvalid 请求 URI

docs 的原始链接。

有人可以帮忙吗?

【问题讨论】:

    标签: android api youtube subscription


    【解决方案1】:

    尝试对您的开发者密钥、authtoken 和订阅 ID 进行 urlencode。

    【讨论】:

    猜你喜欢
    • 2013-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-28
    • 1970-01-01
    相关资源
    最近更新 更多