1

I am trying to get my own channel Subscriber list using

https://www.googleapis.com/youtube/v3/subscriptions?part=subscriberSnippet&mySubscribers=true&key={APPKEY}&channelId={channel ID}

But its given me error

  {
 "error": {
  "errors": [
   {
    "domain": "youtube.parameter",
    "reason": "incompatibleParameters",
    "message": "Incompatible parameters specified in the request: channelId, mySubscribers",
    "locationType": "parameter",
    "location": ""
   }
  ],
  "code": 400,
  "message": "Incompatible parameters specified in the request: channelId, mySubscribers"
 }
}
Ajeet Kumar
  • 805
  • 1
  • 7
  • 26

3 Answers3

1

The documentation for the parameter mySubscribersof subscribers.list states:

This parameter can only be used in a properly authorized request.

It is important to understand that there are two ways to query the YouTube API:

  1. With an API key. You can generate a key in the Cloud Console and would then append it to the request with &key=, just like you did.

  2. With an authorization token. A token authorizes you to access the API in behalf of another user (channel). Then you can not only retrieve data, but also change channel or video information or upload videos. Furthermore, you can access data that only the respective user can see, but that is not visible to the public. See this guide on how to use the OAuth 2.0 framework in order to access private user data.

The latter process is a little more complicated, but it is necessary if you wish to use the mySubscriptions or mine parameters. These parameters are not available when simply using an API key because an API key is not tied to a user/channel.


Since you wrote that you want to get your "own channel Subscriber list" I assume you are interested in a list of people that have subscribed to you and not a list of people that you have subscribed to. For that scenario you can actually not use the channelId parameter of the subscriptions.list endpoint, since the documentation states:

The channelId parameter specifies a YouTube channel ID. The API will only return that channel's subscriptions.

(In practice that means all the channels that you have subscribed to, which is not what you want.)

In order to retrieve a list of people that have subscribed to your channel, you need to authorize your request using an OAuth 2.0 token (see the guide linked above).

Also note that just as you won't see these subscribers via the YouTube website, they won't show up in the API if a user decides to hide their subscriptions in their privacy settings.

paolo
  • 2,528
  • 3
  • 17
  • 25
0
<?php
$apiKey = 'puthereyouapikey';
$chanelId = 'channelid';
$json = json_decode((file_get_contents('https://www.googleapis.com/youtube/v3/channels?part=statistics&id='.$channelId.'&key='.$apiKey)), true);
echo ($json != NULL) ? (($json['items']['0']['statistics']['subscriberCount'])) : '';
?>

The YouTube API v3.0

**You Can Get Your Api key From Here !!**

1) Log in to a Google account and go to https://console.developers.google.com/. You may have to start a new project.

2) Navigate to APIs & auth and go to Public API Access -> Create a New Key

3) Choose the option you need (I used 'browser applications') This will give you an API key.

4) Navigate to your channel in YouTube and look at the URL. The channel ID is here: https://www.youtube.com/channel/YOUR_CHANNEL_ID

5) Use the API key and channel ID to get your result with this query: https://www.googleapis.com/youtube/v3/channels?part=statistics&id=YOUR_CHANNEL_ID&key=YOUR_API_KEY

**You Can Get Your ChanelId From Here **

https://www.youtube.com/account_advanced

RïshïKêsh Kümar
  • 4,734
  • 1
  • 24
  • 36
  • Your answer is simply wrong. What you outline here is not the OAuth workflow. Also, the method you describe would only yield the number of subscribers for a channel, not the list. – paolo Apr 15 '17 at 11:17
  • So, You tell me How To Display The All List Of User Subscribers , If Know Very Well .. I am Waiting 4 Ans – RïshïKêsh Kümar Apr 15 '17 at 13:29
0

I haven't tried this specifically but I suspect if you remove

&key={APPKEY}&channelId={channel ID}

from your request and instead use

&access_token={access token}

you'll get what you're looking for. Sometimes if you're using the APIs Explorer it will mislead you by telling you to authenticate with a key when what you really need is to use an access token that you captured during an OAuth 2.0 flow from the account you're trying to get the data from.

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Ben P.
  • 1