Youtube api Can';t使用API删除Youtube订阅

Youtube api Can';t使用API删除Youtube订阅,youtube-api,youtube-data-api,Youtube Api,Youtube Data Api,我已经使用oauth登录为Youtube API设置了代码。登录似乎工作正常。我甚至可以看到请求击中了我的分析。但是,当我运行代码取消订阅某个频道时,它在我给它的任何频道ID上都不起作用。应该注意的是(请参阅javascript的“完整示例”选项)。。。我猜代码是正确的,这是另一个身份验证/查找问题 API代码: alert("deleting steven!!!!!!"); buildApiRequest('DELETE', '/youtube/v3/sub

我已经使用oauth登录为Youtube API设置了代码。登录似乎工作正常。我甚至可以看到请求击中了我的分析。但是,当我运行代码取消订阅某个频道时,它在我给它的任何频道ID上都不起作用。应该注意的是(请参阅javascript的“完整示例”选项)。。。我猜代码是正确的,这是另一个身份验证/查找问题


API代码:

 alert("deleting steven!!!!!!");
 buildApiRequest('DELETE',
               '/youtube/v3/subscriptions',
               {'id': 'UCMtFAi84ehTSYSE9XoHefig'}); 
function executeRequest(request) {
    request.execute(function(response) {
      console.log(response);
    });
  }

  function buildApiRequest(requestMethod, path, params, properties) {
    params = removeEmptyParams(params);
    var request;
    if (properties) {
      var resource = createResource(properties);
      request = gapi.client.request({
          'body': resource,
          'method': requestMethod,
          'path': path,
          'params': params
      });
    } else {
      request = gapi.client.request({
          'method': requestMethod,
          'path': path,
          'params': params
      });
    }
    executeRequest(request);
  }
    {
 "error": {
  "errors": [
   {
    "domain": "youtube.subscription",
    "reason": "subscriptionNotFound",
    "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
   }
  ],
  "code": 404,
  "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
 }
}
buildApiRequest('GET',
                '/youtube/v3/subscriptions',
                {'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
                'mine': 'true',
                'part': 'snippet,contentDetails'});
{
  "kind": "youtube#subscription",
  "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
  "id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
  "snippet": {
    "publishedAt": "2018-09-30T16:51:47.000Z",
    "title": "Rebeca Willett",
    "description": "",
    "resourceId": {
      "kind": "youtube#channel",
      "channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
    },
    "channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
    "thumbnails": {
    ...
}
股票Youtube API代码:

 alert("deleting steven!!!!!!");
 buildApiRequest('DELETE',
               '/youtube/v3/subscriptions',
               {'id': 'UCMtFAi84ehTSYSE9XoHefig'}); 
function executeRequest(request) {
    request.execute(function(response) {
      console.log(response);
    });
  }

  function buildApiRequest(requestMethod, path, params, properties) {
    params = removeEmptyParams(params);
    var request;
    if (properties) {
      var resource = createResource(properties);
      request = gapi.client.request({
          'body': resource,
          'method': requestMethod,
          'path': path,
          'params': params
      });
    } else {
      request = gapi.client.request({
          'method': requestMethod,
          'path': path,
          'params': params
      });
    }
    executeRequest(request);
  }
    {
 "error": {
  "errors": [
   {
    "domain": "youtube.subscription",
    "reason": "subscriptionNotFound",
    "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
   }
  ],
  "code": 404,
  "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
 }
}
buildApiRequest('GET',
                '/youtube/v3/subscriptions',
                {'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
                'mine': 'true',
                'part': 'snippet,contentDetails'});
{
  "kind": "youtube#subscription",
  "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
  "id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
  "snippet": {
    "publishedAt": "2018-09-30T16:51:47.000Z",
    "title": "Rebeca Willett",
    "description": "",
    "resourceId": {
      "kind": "youtube#channel",
      "channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
    },
    "channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
    "thumbnails": {
    ...
}

错误如下:

 alert("deleting steven!!!!!!");
 buildApiRequest('DELETE',
               '/youtube/v3/subscriptions',
               {'id': 'UCMtFAi84ehTSYSE9XoHefig'}); 
function executeRequest(request) {
    request.execute(function(response) {
      console.log(response);
    });
  }

  function buildApiRequest(requestMethod, path, params, properties) {
    params = removeEmptyParams(params);
    var request;
    if (properties) {
      var resource = createResource(properties);
      request = gapi.client.request({
          'body': resource,
          'method': requestMethod,
          'path': path,
          'params': params
      });
    } else {
      request = gapi.client.request({
          'method': requestMethod,
          'path': path,
          'params': params
      });
    }
    executeRequest(request);
  }
    {
 "error": {
  "errors": [
   {
    "domain": "youtube.subscription",
    "reason": "subscriptionNotFound",
    "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
   }
  ],
  "code": 404,
  "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
 }
}
buildApiRequest('GET',
                '/youtube/v3/subscriptions',
                {'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
                'mine': 'true',
                'part': 'snippet,contentDetails'});
{
  "kind": "youtube#subscription",
  "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
  "id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
  "snippet": {
    "publishedAt": "2018-09-30T16:51:47.000Z",
    "title": "Rebeca Willett",
    "description": "",
    "resourceId": {
      "kind": "youtube#channel",
      "channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
    },
    "channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
    "thumbnails": {
    ...
}

请记住,您必须发送的ID不是频道ID,而是订阅的ID。 您可以通过发送请求以检查频道的订阅来获得它。比如说

请求:

 alert("deleting steven!!!!!!");
 buildApiRequest('DELETE',
               '/youtube/v3/subscriptions',
               {'id': 'UCMtFAi84ehTSYSE9XoHefig'}); 
function executeRequest(request) {
    request.execute(function(response) {
      console.log(response);
    });
  }

  function buildApiRequest(requestMethod, path, params, properties) {
    params = removeEmptyParams(params);
    var request;
    if (properties) {
      var resource = createResource(properties);
      request = gapi.client.request({
          'body': resource,
          'method': requestMethod,
          'path': path,
          'params': params
      });
    } else {
      request = gapi.client.request({
          'method': requestMethod,
          'path': path,
          'params': params
      });
    }
    executeRequest(request);
  }
    {
 "error": {
  "errors": [
   {
    "domain": "youtube.subscription",
    "reason": "subscriptionNotFound",
    "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
   }
  ],
  "code": 404,
  "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
 }
}
buildApiRequest('GET',
                '/youtube/v3/subscriptions',
                {'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
                'mine': 'true',
                'part': 'snippet,contentDetails'});
{
  "kind": "youtube#subscription",
  "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
  "id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
  "snippet": {
    "publishedAt": "2018-09-30T16:51:47.000Z",
    "title": "Rebeca Willett",
    "description": "",
    "resourceId": {
      "kind": "youtube#channel",
      "channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
    },
    "channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
    "thumbnails": {
    ...
}
响应:

 alert("deleting steven!!!!!!");
 buildApiRequest('DELETE',
               '/youtube/v3/subscriptions',
               {'id': 'UCMtFAi84ehTSYSE9XoHefig'}); 
function executeRequest(request) {
    request.execute(function(response) {
      console.log(response);
    });
  }

  function buildApiRequest(requestMethod, path, params, properties) {
    params = removeEmptyParams(params);
    var request;
    if (properties) {
      var resource = createResource(properties);
      request = gapi.client.request({
          'body': resource,
          'method': requestMethod,
          'path': path,
          'params': params
      });
    } else {
      request = gapi.client.request({
          'method': requestMethod,
          'path': path,
          'params': params
      });
    }
    executeRequest(request);
  }
    {
 "error": {
  "errors": [
   {
    "domain": "youtube.subscription",
    "reason": "subscriptionNotFound",
    "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
   }
  ],
  "code": 404,
  "message": "The subscription that you are trying to delete cannot be found. Check the value of the requests \u003ccode\u003eid\u003c/code\u003e parameter to ensure that it is correct."
 }
}
buildApiRequest('GET',
                '/youtube/v3/subscriptions',
                {'forChannelId': 'UCEhZglE9MQ4zTL5ErNXt5mg',
                'mine': 'true',
                'part': 'snippet,contentDetails'});
{
  "kind": "youtube#subscription",
  "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/KrR9MNb4Xs1eNjWMxAH-f5ccsos\"",
  "id": "Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M",
  "snippet": {
    "publishedAt": "2018-09-30T16:51:47.000Z",
    "title": "Rebeca Willett",
    "description": "",
    "resourceId": {
      "kind": "youtube#channel",
      "channelId": "UCEhZglE9MQ4zTL5ErNXt5mg"
    },
    "channelId": "UCWfZYaoFrUOSoHNhCOOqKCQ",
    "thumbnails": {
    ...
}
在响应中使用ID发送取消订阅请求:

buildApiRequest('DELETE',
                '/youtube/v3/subscriptions',
                {'id': 'Xmg72z6q83hK2hjx0J4ZwNVcgGz8fu9JCjeHu6eIb3M'}); 

这是

我也有这个问题。够奇怪的了,它正在做一些IDS。谢谢你的洞察力,我希望谷歌会有人回应。。。很高兴知道我并不孤单:)仅供参考:我已经在谷歌开了一张罚单: