Volkan
Volkan

Reputation: 49

Youtube Data API V3 access subscriber count

{
 "kind": "youtube#channelListResponse",
 "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/WNxXCvycTyqTjTn9sLJ5toVjBRY\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {

   "kind": "youtube#channel",
   "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/jijTuA_iWn2Kv9aRnqeAWNAcQ6I\"",
   "id": "UCt7iVnJwjBsof8IPLJHCTgQ",
   "statistics": {
    "viewCount": "796662",
    "commentCount": "20",
    "subscriberCount": "257",
    "hiddenSubscriberCount": false,
    "videoCount": "126"
   }
  }
 ]
}

basically how can i echo "subscriberCount". In PHP i can get it with json_encode(). i tried print_r() and it is displayed perfect but i dont know how can i access specific data. i need just subscriber count.

Upvotes: 0

Views: 148

Answers (1)

Cultti
Cultti

Reputation: 91

Without knowing if your origin data is in object or assoc array format I can't give you direct answer.

If your data is in object format you can use

$dta->items[0]->statistics->subscriberCount

However, if your data is assoc array you can use

$dta['items'][0]['statistics']['subscriberCount']

Upvotes: 1

Related Questions