我想在我的应用程序中执行youtube api V3的删除订阅。但我无法得到它。这是我的代码是
HttpDelete httDelete = new HttpDelete("https://www.googleapis.com/youtube/v3/subscriptions");
httDelete.setHeader("Content-Type", "application/json");
httDelete.setHeader("Authorization",MY_ACCESS_TOKEN);
httDelete.setHeader("id",channelId");
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httDelete);
String responseString = StreamUtils.convertToString(response.getEntity().getContent());
这是我的回应
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Required parameter: id",
"locationType": "parameter",
"location": "id"
}
],
"code": 400,
"message": "Required parameter: id"
}
请给我任何建议。我在等待你的快速回复。
您需要在请求正文中指定"id",而不是在标头上指定。如
删除 https://www.googleapis.com/youtube/v3/subscriptions?id=id&key={YOUR_API_KEY}
但我建议你使用YouTube API Java客户端库,以便于使用。
在 YouTube Direct Lite for Android 项目上有一个 Android 工作示例。