{"id":2811,"date":"2017-06-21T04:20:48","date_gmt":"2017-06-21T04:20:48","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=2811"},"modified":"2017-06-21T04:20:48","modified_gmt":"2017-06-21T04:20:48","slug":"8-youtube-data-api-activities-list-function","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2017\/06\/21\/8-youtube-data-api-activities-list-function\/","title":{"rendered":"8 &#8211; YouTube Data API &#8211; Activities &#8211; list function"},"content":{"rendered":"            <script type=\"text\/javascript\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/plugins\/wordpress-code-snippet\/scripts\/shBrushPhp.js\"><\/script>\n<p style=\"text-align: center;\"><strong>This is article 8 of the YouTube API With PHP series.<\/strong><\/p>\n<p>We will see how to work with YouTube Activities. An Activity is any task performed within a Channel like uploading a video or by a User eg.liking a video.\u00a0 There are two functions available for Activities<\/p>\n<p><strong>1.list<\/strong><\/p>\n<p><strong>\u00a0<\/strong>The Request URL is<\/p>\n<pre><span style=\"color: #999999;\">GET https:\/\/www.googleapis.com\/YouTube\/v3\/activities<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Parameters<\/strong><\/p>\n<ul>\n<li><strong>key<\/strong> (string) required. Your API key<\/li>\n<li><strong>part<\/strong> (string) required. One or all of the below, comma separated\n<ul>\n<li>\u201cid\u201d<\/li>\n<li>\u201ccontentDetails\u201d<\/li>\n<li>\u201csnippet\u201d<\/li>\n<\/ul>\n<\/li>\n<li>(One of the filters below) required. (string)\n<ul>\n<li>channelId (string) unique id of a Channel<\/li>\n<li>mine (boolean). Set to true to retrieve an authenticated user\u2019s activities<\/li>\n<\/ul>\n<\/li>\n<li><strong>maxResults<\/strong> (int) optional. max results to return. Valid range 0-50. default value is 5<\/li>\n<li><strong>pageToken<\/strong> (string) optional. used to move forward or backward through the results<\/li>\n<li><strong>publishedAfter<\/strong> (datetime) optional. Specifies a date and time after which an Activity occurred. Format is YYYY-MM-DDThh:mm:ss.sZ . You can also specify a date without time .<\/li>\n<li><strong>publishedBefore<\/strong> (datetime) optional. Specifies a date and time before which an Activity occurred. Format is YYYY-MM-DDThh:mm:ss.sZ . You can also specify a date without time<\/li>\n<li><strong>regionCode<\/strong> (string) optional. Specifies the two letter international code for the country for which results are NOT restricted. By default, most channels and users do not restrict display of their data in certain regions, so this parameter won\u2019t have an effect. So if you specify regionCode=AU , it will show results which are allowed to be shown in Australia.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Example Requests<\/strong><\/p>\n<p>Fetch 5 results for a channel.<\/p>\n<p>https:\/\/www.googleapis.com\/YouTube\/v3\/activities?part=snippet,contentDetails,id&#038;channelId=xxxx&#038;maxResults=5&#038;key=xxx<\/p>\n<p>Fetch 5 results for a channel for all activities before 10 May, 2017<\/p>\n<p>https:\/\/www.googleapis.com\/YouTube\/v3\/activities?part=snippet,contentDetails,id&#038;channelId=xxxx&#038;maxResults=5&#038;key=xxx&#038;publishedBefore=2017-05-10T20:00:01.000Z<\/p>\n<p>Fetch 5 results for a channel for all activities after 10 May, 2017<\/p>\n<p>https:\/\/www.googleapis.com\/YouTube\/v3\/activities?part=snippet,contentDetails,id&#038;channelId=xxxx&#038;maxResults=5&#038;key=xxx&#038;publishedAfter=2017-05-10T20:00:01.000Z<\/p>\n<p>Fetch 5 results for a channel for all activities allowed to be shown in Australia<\/p>\n<p>https:\/\/www.googleapis.com\/YouTube\/v3\/activities?part=snippet,contentDetails,id&#038;channelId=xxxx&#038;maxResults=5&#038;key=xxx&#038;regionCode=AU<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Response<\/strong><\/p>\n<p><strong>\u00a0<\/strong>A successful request will return the following JSON response:<\/p>\n<p><pre class=\"brush: php\">{\r\n  &quot;kind&quot;: &quot;YouTube#activityListResponse&quot;,\r\n  &quot;etag&quot;: etag,\r\n  &quot;nextPageToken&quot;: string,\r\n  &quot;prevPageToken&quot;: string,\r\n  &quot;pageInfo&quot;: {\r\n    &quot;totalResults&quot;: integer,\r\n    &quot;resultsPerPage&quot;: integer\r\n  },\r\n  &quot;items&quot;: [\r\n    (Activity Resource)\r\n  ]\r\n}\r\n<\/pre><\/p>\n<p>The Response components are explained below:<\/p>\n<ul>\n<li><strong>kind<\/strong> (string) \u201cYouTube#activityListResponse.\u201d<\/li>\n<li><strong>etag<\/strong> (string) See ETags Explained section<\/li>\n<li><strong>nextPageToken<\/strong> (string) token for the next page<\/li>\n<li><strong>prevPageToken<\/strong> (string) token for the previous page<\/li>\n<li><strong>totalResults<\/strong> (int) total count of results obtained<\/li>\n<li><strong>resultsPerPage<\/strong> (int) results per page requested<\/li>\n<li><strong>items<\/strong> (array) array of Activity Resource items returned<\/li>\n<\/ul>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Activity Resource<\/strong><\/p>\n<p>The items returned in an Activities list request are an array of Activity Resource objects. The JSON structure is shown below:<\/p>\n<p><pre class=\"brush: php\">{\r\n  &quot;kind&quot;: &quot;YouTube#activity&quot;,\r\n  &quot;etag&quot;: etag,\r\n  &quot;id&quot;: string,\r\n  &quot;snippet&quot;: {\r\n\t&quot;publishedAt&quot;: datetime,\r\n\t&quot;channelId&quot;: string,\r\n\t&quot;title&quot;: string,\r\n\t&quot;description&quot;: string,\r\n\t&quot;thumbnails&quot;: {\r\n  \t\t(key): {\r\n    \t\t\t&quot;url&quot;: string,\r\n    \t\t\t&quot;width&quot;: unsigned integer,\r\n    \t\t\t&quot;height&quot;: unsigned integer\r\n  \t\t}\r\n\t},\r\n\t&quot;channelTitle&quot;: string,\r\n\t&quot;type&quot;: string,\r\n\t&quot;groupId&quot;: string\r\n  },\r\n  &quot;contentDetails&quot;: {\r\n\t&quot;upload&quot;: {\r\n  \t\t&quot;videoId&quot;: string\r\n\t},\r\n\t&quot;like&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t&quot;kind&quot;: string,\r\n    \t\t&quot;videoId&quot;: string,\r\n  \t}\r\n\t},\r\n\t&quot;favorite&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;videoId&quot;: string,\r\n  \t\t}\r\n\t},\r\n\t&quot;comment&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;videoId&quot;: string,\r\n    \t\t\t&quot;channelId&quot;: string,\r\n  \t\t}\r\n\t},\r\n\t&quot;subscription&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;channelId&quot;: string,\r\n  \t\t}\r\n\t},\r\n\t&quot;playlistItem&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;videoId&quot;: string,\r\n  \t\t},\r\n  \t\t&quot;playlistId&quot;: string,\r\n  \t\t&quot;playlistItemId&quot;: string\r\n\t},\r\n\t&quot;recommendation&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;videoId&quot;: string,\r\n    \t\t\t&quot;channelId&quot;: string,\r\n  \t\t},\r\n  \t\t&quot;reason&quot;: string,\r\n  \t\t&quot;seedResourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;videoId&quot;: string,\r\n    \t\t\t&quot;channelId&quot;: string,\r\n    \t\t\t&quot;playlistId&quot;: string\r\n  \t\t}\r\n\t},\r\n\t&quot;bulletin&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;videoId&quot;: string,\r\n    \t\t\t&quot;channelId&quot;: string,\r\n    \t\t\t&quot;playlistId&quot;: string\r\n  \t\t}\r\n\t},\r\n\t&quot;social&quot;: {\r\n  \t\t&quot;type&quot;: string,\r\n  \t\t&quot;resourceId&quot;: {\r\n    \t\t\t&quot;kind&quot;: string,\r\n    \t\t\t&quot;videoId&quot;: string,\r\n    \t\t\t&quot;channelId&quot;: string,\r\n    \t\t\t&quot;playlistId&quot;: string\r\n  \t\t},\r\n  \t\t&quot;author&quot;: string,\r\n  \t\t&quot;referenceUrl&quot;: string,\r\n  \t\t&quot;imageUrl&quot;: string\r\n\t},\r\n\t&quot;channelItem&quot;: {\r\n  \t\t&quot;resourceId&quot;: {\r\n  \t\t}\r\n\t},\r\n  }\r\n}\r\n<\/pre><\/p>\n<p>An explanation of the various fields are given below:<\/p>\n<ul>\n<li><strong>kind<\/strong> (string) This value is always \u201cYouTube#activity\u201d<\/li>\n<li><strong>etag<\/strong> (string) See ETags Explained section<\/li>\n<li><strong>id<\/strong> (string) unique id of this Activity<\/li>\n<li><strong>publishedAt<\/strong> (datetime) Date and time of this Activity. (YYYY-MM-DDThh:mm:ss.sZ) format.<\/li>\n<li><strong>channelId<\/strong> (string) Id of the Channel associated with this Activity<\/li>\n<li><strong>title<\/strong> (string) title of the resource for this Activity<\/li>\n<li><strong>description<\/strong> (string) description of the resource for this Activity<\/li>\n<li><strong>thumbnails.(key)<\/strong> (string) . Possible values are :\n<ul>\n<li>\u201cdefault\u201d default thumbnail image. For videos it is 120px x 90px. For\u00a0 a Channel it is 88px x 88px .<\/li>\n<li>\u201cmedium\u201d medium resolution thumbnail image. For videos it is 320px\u00a0 x 180px. For\u00a0 a Channel it is 240px x 240px .<\/li>\n<li>\u201chigh\u201d high resolution thumbnail image. For videos it is 480px\u00a0 x 360. For\u00a0 a Channel it is 800px x 800px.<\/li>\n<li>\u201cstandard\u201d better resolution than high thumbnail image. For videos it is 640px\u00a0 x 480px. For\u00a0 a Channel it is not available.<\/li>\n<li>\u201cmaxres\u201d highest resolution possible. or videos it is 1280px x 720. For\u00a0 a Channel it is not available.<\/li>\n<\/ul>\n<\/li>\n<li><strong>thumbnails.(key).url<\/strong> (string) url of thumbnail<\/li>\n<li><strong>thumbnails.(key).width<\/strong> (int) width in pixels.<\/li>\n<li><strong>thumbnails.(key).height<\/strong> (int) height in pixels.<\/li>\n<li><strong>title (string) title<\/strong> of Channel where this Activity is taking place.<\/li>\n<li><strong>type (string).<\/strong> Possible values are\n<ul>\n<li>\u201cbulletin\u201d<\/li>\n<li>\u201cchannelItem\u201d<\/li>\n<li>\u201cfavorite\u201d<\/li>\n<li>\u201clike\u201d<\/li>\n<li>\u201cplaylistItem\u201d<\/li>\n<li>\u201cpromotedItem\u201d<\/li>\n<li>\u201crecommendation\u201d<\/li>\n<li>\u201csocial\u201d<\/li>\n<li>\u201csubscription\u201d<\/li>\n<li>\u201cupload\u201d<\/li>\n<\/ul>\n<\/li>\n<li><strong>groupId<\/strong> (string) The group ID associated with the activity. A group ID identifies user events that are associated with the same user and resource. For example, if a user rates a video and marks the same video as a favorite, the entries for those events would have the same group ID in the user&#8217;s activity feed.<\/li>\n<li><strong>upload<\/strong> (object) The upload object contains information about the uploaded video. This property is only present if the snippet.type is \u201cupload\u201d.<\/li>\n<li><strong>upload.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the uploaded video.<\/li>\n<li><strong>like<\/strong> (object) The like object contains information about a resource that received a positive (like) rating. This property is only present if the snippet.type is \u201clike\u201d.<\/li>\n<li><strong>like.resourceId.kind<\/strong> (string) The type of the API resource.<\/li>\n<li><strong>like.resourceId.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the video, if the rated resource is a video. This property is only present if the resourceId.kind is YouTube#video.<\/li>\n<li><strong>favorite<\/strong> (object) The favorite object contains information about a video that was marked as a favorite video. This property is only present if the snippet.type is favorite.<\/li>\n<li><strong>favorite.resourceId.kind<\/strong> (string) The type of the API resource<\/li>\n<li><strong>favorite.resourceId.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the favorite video. This property is only present if the resourceId.kind is YouTube#video.<\/li>\n<li><strong>subscription<\/strong> (object) The subscription object contains information about a channel that a user subscribed to. This property is only present if the snippet.type is \u201csubscription\u201d.<\/li>\n<li><strong>subscription.resourceId.kind<\/strong> (string) The type of the API resource.<\/li>\n<li><strong>subscription.resourceId.channelId<\/strong> (string) The ID that YouTube uses to uniquely identify the channel that the user subscribed to. This property is only present if the resourceId.kind is \u201cYouTube#channel\u201d.<\/li>\n<li><strong>playlistItem<\/strong> (object) The playlistItem object contains information about a new playlist item. This property is only present if the snippet.type is \u201cplaylistItem\u201d.<\/li>\n<li><strong>playlistItem.resourceId.kind<\/strong> (string) The type of the API resource<\/li>\n<li><strong>playlistItem.resourceId.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the video that was added to the playlist. This property is only present if the resourceId.kind is \u201cYouTube#video\u201d.<\/li>\n<li><strong>playlistItem.playlistId<\/strong> (string) The value that YouTube uses to uniquely identify the playlist<\/li>\n<li><strong>playlistItem.playlistItemId<\/strong> (string) The value that YouTube uses to uniquely identify the item in the playlist.<\/li>\n<li><strong>recommendation<\/strong> (object) The recommendation object contains information about a recommended resource. This property is only present if the snippet.type is recommendation.<\/li>\n<li><strong>recommendation.resourceId.kind<\/strong> (string) The type of the API resource.<\/li>\n<li><strong>recommendation.resourceId.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the video, if the recommended resource is a video. This property is only present if the resourceId.kind is \u201cYouTube#video\u201d.<\/li>\n<li><strong>recommendation.resourceId.<\/strong>channelId (string) The ID that YouTube uses to uniquely identify the channel, if the recommended resource is a channel. This property is only present if the resourceId.kind is YouTube#channel.<\/li>\n<li><strong>recommendation.reason<\/strong> (string) Valid values are\n<ul>\n<li>\u201cvideoFavorited\u201d<\/li>\n<li>\u201cvideoLiked\u201d<\/li>\n<li>\u201cvideoWatched\u201d<\/li>\n<\/ul>\n<\/li>\n<li><strong>recommendation.seedResourceId<\/strong> (object) The seedResourceId object contains information about the resource that caused the recommendation.<\/li>\n<li><strong>recommendation.seedResourceId.kind<\/strong> (string) The type of the API resource.<\/li>\n<li><strong>recommendation.seedResourceId.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the video, if the recommendation was caused by a particular video. This property is only present if the seedResourceId.kind is \u201cYouTube#video\u201d.<\/li>\n<li><strong>recommendation.seedResourceId.channelId<\/strong> (string) The ID that YouTube uses to uniquely identify the channel, if the recommendation was caused by a particular channel. This property is only present if the seedResourceId.kind is \u201cYouTube#channel\u201d.<\/li>\n<li><strong>recommendation.seedResourceId.playlistId<\/strong> (string) The ID that YouTube uses to uniquely identify the playlist, if the recommendation was caused by a particular playlist. This property is only present if the seedResourceId.kind is \u201cYouTube#playlist\u201d.<\/li>\n<li><strong>bulletin<\/strong> (object) The bulletin object contains details about a channel bulletin post. This object is only present if the snippet.type is \u201cbulletin\u201d.<\/li>\n<li><strong>bulletin.resourceId.kind<\/strong> (string) The type of the API resource.<\/li>\n<li><strong>bulletin.resourceId.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the video featured in a bulletin post, if the post refers to a video. This property will only be present if the value of the bulletin.resourceId.kind property is \u201cYouTube#video\u201d<\/li>\n<li><strong>bulletin.resourceId.channelId<\/strong> (string) The ID that YouTube uses to uniquely identify the channel featured in a bulletin post, if the post refers to a channel. This property will only be present if the value of the bulletin.resourceId.kind property is \u201cYouTube#channel\u201d.<\/li>\n<li><strong>bulletin.resourceId.playlistId<\/strong> (string) The ID that YouTube uses to uniquely identify the playlist featured in a bulletin post, if the post refers to a playlist. This property will only be present if the value of the bulletin.resourceId.kind property is \u201cYouTube#playlist\u201d<\/li>\n<li><strong>social<\/strong> (object) The social object contains details about a social network post. This property is only present if the snippet.type is \u201csocial\u201d.<\/li>\n<li><strong>social.type<\/strong> (string) Possible values are:\n<ul>\n<li>\u201cfacebook\u201d<\/li>\n<li>\u201cgooglePlus\u201d<\/li>\n<li>\u201ctwitter\u201d<\/li>\n<li>\u201cunspecified\u201d<\/li>\n<\/ul>\n<\/li>\n<li><strong>social.resourceId.kind<\/strong> (string) The type of the API resource.<\/li>\n<li><strong>social.resourceId.videoId<\/strong> (string) The ID that YouTube uses to uniquely identify the video featured in a social network post, if the post refers to a video. This property will only be present if the value of the social.resourceId.kind property is \u201cYouTube#video\u201d.<\/li>\n<li><strong>social.resourceId.channelId<\/strong> (string) The ID that YouTube uses to uniquely identify the channel featured in a social network post, if the post refers to a channel. This property will only be present if the value of the social.resourceId.kind property is \u201cYouTube#channel\u201d.<\/li>\n<li><strong>social.resourceId.playlistId<\/strong> (string) The ID that YouTube uses to uniquely identify the playlist featured in a social network post, if the post refers to a playlist. This property will only be present if the value of the social.resourceId.kind property is \u201cYouTube#playlist\u201d.<\/li>\n<li><strong>social.author<\/strong> (string) The author of the social network post.<\/li>\n<li><strong>social.referenceUrl<\/strong> (string) The URL of the social network post.<\/li>\n<li><strong>social.imageUrl<\/strong> (string) An image of the post&#8217;s author.<\/li>\n<li><strong>channelItem<\/strong> (object) The channelItem object contains details about a resource that was added to a channel. This property is only present if the snippet.type is \u201cchannelItem\u201d.<\/li>\n<li><strong>channelItem.resourceId<\/strong> (object) The resourceId object contains information that identifies the resource that was added to the channel.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Here is sample code which fetches activities for a Channel. This only requires the API Key<\/p>\n<p><pre class=\"brush: php\">&lt;?php\r\n    error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);\r\n    set_time_limit(60 * 3);\r\n    \r\n    $g_YouTubeDataAPIKey = &quot;****&quot;;\r\n    $channelId = &quot;UCIJ0lLcABPdYGp7pRMGccAQ&quot;;\r\n    \r\n   \t \/\/ make api request\r\n   \t $url = &quot;https:\/\/www.googleapis.com\/YouTube\/v3\/activities?part=snippet,contentDetails,id&amp;channelId=&quot; .\r\n   \t $channelId. &quot;&amp;maxResults=5&amp;key=&quot; . $g_YouTubeDataAPIKey;\r\n\r\n   \t $curl = curl_init();\r\n   \t curl_setopt_array($curl, array(\r\n   \t\t\t\t CURLOPT_RETURNTRANSFER =&gt; 1,\r\n   \t\t\t\t CURLOPT_URL =&gt; $url,\r\n   \t\t\t\t CURLOPT_USERAGENT =&gt; &#039;YouTube API Tester&#039;,\r\n   \t\t\t\t CURLOPT_SSL_VERIFYPEER =&gt; 1,\r\n   \t\t\t\t CURLOPT_SSL_VERIFYHOST=&gt; 0,\r\n   \t\t\t\t CURLOPT_CAINFO =&gt; &quot;..\/..\/cert\/cacert.pem&quot;,\r\n   \t\t\t\t CURLOPT_CAPATH =&gt; &quot;..\/..\/cert\/cacert.pem&quot;,\r\n   \t\t\t\t CURLOPT_FOLLOWLOCATION =&gt; TRUE\r\n   \t\t\t\t ));\r\n   \t $resp = curl_exec($curl);\r\n\r\n   \t curl_close($curl);\r\n\r\n   \t \r\n   \t if ($resp) {\r\n   \t\t $json = json_decode($resp);\r\n   \t\t if ($json) {\r\n   \t\t\t echo(&quot;JSON decoded&lt;br&gt;&quot;);\r\n   \t\t\t $total = $json-&gt;pageInfo-&gt;totalResults;\r\n\r\n   \t\t\t $items = $json-&gt;items;\r\n   \t\t }\r\n   \t\t else\r\n   \t\t\t exit(&quot;Error. could not parse JSON.&quot; . json_last_error_msg());\r\n\r\n   \t \r\n   \t\t foreach($items as $item) {\r\n   \t\t\t $publishedAt = $item-&gt;snippet-&gt;publishedAt;\r\n   \t\t\t $channelId = $item-&gt;snippet-&gt;channelId;\r\n   \t\t\t $title = $item-&gt;snippet-&gt;title;\r\n\r\n   \t\t\t $type = $item-&gt;snippet-&gt;type;\r\n   \t\t\t \r\n   \t\t\t $actityKind = &quot;&quot;;\r\n   \t\t\t $activityItemId = &quot;&quot;;\r\n   \t\t\t $activityInfo = &quot;&quot;;\r\n\r\n   \t\t\t if ($type == &quot;bulletin&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;bulletin-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; . $item-&gt;contentDetails-&gt;bulletin-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; . $item-&gt;contentDetails-&gt;bulletin-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;channelItem&quot;) {\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;favorite&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;favorite-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;favorite-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t \r\n\r\n   \t\t\t } else if ($type == &quot;like&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;like-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;like-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;playlistItem&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;promotedItem&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;promotedItem-&gt;resourceId-&gt;kind;\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;recommendation&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n   \t\t\t \r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Reason &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;reason;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Resource Id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Resource Kind &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;kind;\r\n   \t\t\t\t \r\n   \t\t\t\t $seedResourceKind =  $item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;kind;\r\n   \t\t\t \tif ($seedResourceKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt; Seed Video id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($seedResourceKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Channel id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($seedResourceKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Playlist id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n    \r\n   \t\t\t } else if ($type == &quot;social&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;kind;\r\n   \t\t\t\t $activityInfo = $item-&gt;contentDetails-&gt;social-&gt;type;\r\n   \t\t\t\t \r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Author=&quot; .$item-&gt;contentDetails-&gt;social-&gt;author;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;URL=&quot; .$item-&gt;contentDetails-&gt;social-&gt;referenceUrl;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Author Image=&quot; .$item-&gt;contentDetails-&gt;social-&gt;imageUrl;\r\n\r\n   \t \r\n\r\n   \t\t\t } else if ($type == &quot;subscription&quot;) {\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;subscription-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;subscription-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;subscription-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;upload&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;upload-&gt;resourceId-&gt;kind;\r\n   \t\t\t\t \r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;upload-&gt;videoId;\r\n\r\n\r\n   \t\t\t }\r\n\r\n   \t\t\t echo(&quot;Date:&quot; . $publishedAt . &quot;, Channel Id:&quot; . $channelId . &quot; &quot; . $title . &quot;&lt;br&gt;&quot;);\r\n   \t\t\t echo(&quot;Activity Type:&quot; . $type . &quot;&lt;br&gt;&quot;);\r\n   \t\t\t echo(&quot;Kind: &quot; . $activityKind . &quot;&lt;br&gt;&quot;);\r\n   \t\t\t echo($activityInfo);\r\n   \t\t\t echo(&quot;&lt;hr&gt;&quot;);\r\n\r\n   \t\t } \/\/ foreach\r\n   \t } \/\/ if resp\r\n\r\n   \t \r\n    \r\n?&gt;\r\n<\/pre><\/p>\n<p>Here is the output:<\/p>\n<pre><span style=\"color: #999999;\">JSON decoded<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-19T16:06:04.000Z, Channel Id:UCIJ0lLcABPdYGp7pRMGccAQ Fails of the Week: This Time, It's Personal (May 2017)<\/span>\r\n<span style=\"color: #999999;\">Activity Type:like<\/span>\r\n<span style=\"color: #999999;\">Kind: YouTube#video<\/span>\r\n\r\n<span style=\"color: #999999;\">Video id 8dlSd0xW8bQ<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-19T12:20:49.000Z, Channel Id:UCIJ0lLcABPdYGp7pRMGccAQ PEOPLE ARE AWESOME 2017 | BEST OF THE WEEK (Ep. 26)<\/span>\r\n<span style=\"color: #999999;\">Activity Type:upload<\/span>\r\n<span style=\"color: #999999;\">Kind:<\/span>\r\n\r\n\r\n<span style=\"color: #999999;\">Video id YQlmh5Egx5E<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-19T12:20:49.000Z, Channel Id:UCIJ0lLcABPdYGp7pRMGccAQ PEOPLE ARE AWESOME 2017 | BEST OF THE WEEK (Ep. 26)<\/span>\r\n<span style=\"color: #999999;\">Activity Type:bulletin<\/span>\r\n<span style=\"color: #999999;\">Kind: YouTube#video<\/span>\r\n\r\n<span style=\"color: #999999;\">Video id YQlmh5Egx5E<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-16T14:33:35.000Z, Channel Id:UCIJ0lLcABPdYGp7pRMGccAQ SPOTLIGHT: Natalie \"Killface\" Morgan - Muay Thai Fighter | PEOPLE ARE AWESOME 2017<\/span>\r\n<span style=\"color: #999999;\">Activity Type:upload<\/span>\r\n<span style=\"color: #999999;\">Kind:<\/span>\r\n\r\n\r\n<span style=\"color: #999999;\">Video id zXyFFCZG4HQ<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-12T12:04:12.000Z, Channel Id:UCIJ0lLcABPdYGp7pRMGccAQ PEOPLE ARE AWESOME 2017 | BEST OF THE WEEK (Ep. 25)<\/span>\r\n<span style=\"color: #999999;\">Activity Type:upload<\/span>\r\n<span style=\"color: #999999;\">Kind:<\/span>\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Below is code which fetches the Activities of a User. This requires OAuth and the API key.<\/p>\n<p><pre class=\"brush: php\">&lt;?php\r\n    error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);\r\n    set_time_limit(60 * 3);\r\n    session_start();\r\n\r\n    $clientId = &quot;****&quot;;\r\n    $clientSecret = &quot;***&quot;;\r\n    $g_YouTubeDataAPIKey = &quot;***&quot;;\r\n\r\n  \r\n    \r\n\r\n    $_SESSION[&quot;code_id&quot;] = $_SERVER[&quot;PHP_SELF&quot;];\r\n    \r\n    if ($_SESSION[&quot;access_token&quot;] == null || $_SESSION[&quot;access_token&quot;] == &quot;&quot;) {\r\n   \t \/\/ check for oauth response\r\n   \t header(&quot;Location: ..\/..\/init-login.php&quot;);\r\n   \t exit;\r\n    }\r\n   \t \r\n   \t \r\n   \t $accessToken = $_SESSION[&quot;access_token&quot;];\r\n   \t \r\n   \t \/\/ make api request\r\n   \t $url = &quot;https:\/\/www.googleapis.com\/YouTube\/v3\/activities?part=snippet,contentDetails,id&amp;mine=true&amp;maxResults=5&amp;key=&quot; .\r\n   \t\t\t $g_YouTubeDataAPIKey . &quot;&amp;access_token=&quot; . $accessToken;\r\n\r\n   \t $curl = curl_init();\r\n   \t curl_setopt_array($curl, array(\r\n   \t\t\t\t CURLOPT_RETURNTRANSFER =&gt; 1,\r\n   \t\t\t\t CURLOPT_URL =&gt; $url,\r\n   \t\t\t\t CURLOPT_USERAGENT =&gt; &#039;YouTube API Tester&#039;,\r\n   \t\t\t\t CURLOPT_SSL_VERIFYPEER =&gt; 1,\r\n   \t\t\t\t CURLOPT_SSL_VERIFYHOST=&gt; 0,\r\n   \t\t\t\t CURLOPT_CAINFO =&gt; &quot;..\/..\/cert\/cacert.pem&quot;,\r\n   \t\t\t\t CURLOPT_CAPATH =&gt; &quot;..\/..\/cert\/cacert.pem&quot;,\r\n   \t\t\t\t CURLOPT_FOLLOWLOCATION =&gt; TRUE\r\n   \t\t\t\t ));\r\n   \t $resp = curl_exec($curl);\r\n\r\n   \t curl_close($curl);\r\n   \t \r\n    if ($resp) {\r\n   \t\t $json = json_decode($resp);\r\n   \t\t if ($json) {\r\n   \t\t\t echo(&quot;JSON decoded&lt;br&gt;&quot;);\r\n   \t\t\t $total = $json-&gt;pageInfo-&gt;totalResults;\r\n\r\n   \t\t\t $items = $json-&gt;items;\r\n   \t\t }\r\n   \t\t else\r\n   \t\t\t exit(&quot;Error. could not parse JSON.&quot; . json_last_error_msg());\r\n\r\n   \t \r\n   \t\t foreach($items as $item) {\r\n   \t\t\t $publishedAt = $item-&gt;snippet-&gt;publishedAt;\r\n   \t\t\t $channelId = $item-&gt;snippet-&gt;channelId;\r\n   \t\t\t $title = $item-&gt;snippet-&gt;title;\r\n\r\n   \t\t\t $type = $item-&gt;snippet-&gt;type;\r\n   \t\t\t \r\n   \t\t\t $actityKind = &quot;&quot;;\r\n   \t\t\t $activityItemId = &quot;&quot;;\r\n   \t\t\t $activityInfo = &quot;&quot;;\r\n\r\n   \t\t\t if ($type == &quot;bulletin&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;bulletin-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; . $item-&gt;contentDetails-&gt;bulletin-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; . $item-&gt;contentDetails-&gt;bulletin-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;channelItem&quot;) {\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;favorite&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;favorite-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;favorite-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t \r\n\r\n   \t\t\t } else if ($type == &quot;like&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;like-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;like-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;playlistItem&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;playlistItem-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;promotedItem&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;promotedItem-&gt;resourceId-&gt;kind;\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;recommendation&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;kind;\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n   \t\t\t \r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Reason &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;reason;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Resource Id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Resource Kind &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;kind;\r\n   \t\t\t\t \r\n   \t\t\t\t $seedResourceKind =  $item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;kind;\r\n   \t\t\t \tif ($seedResourceKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt; Seed Video id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($seedResourceKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Channel id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($seedResourceKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Seed Playlist id &quot; .$item-&gt;contentDetails-&gt;recommendation-&gt;seedResourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n    \r\n   \t\t\t } else if ($type == &quot;social&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;kind;\r\n   \t\t\t\t $activityInfo = $item-&gt;contentDetails-&gt;social-&gt;type;\r\n   \t\t\t\t \r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;social-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Author=&quot; .$item-&gt;contentDetails-&gt;social-&gt;author;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;URL=&quot; .$item-&gt;contentDetails-&gt;social-&gt;referenceUrl;\r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Author Image=&quot; .$item-&gt;contentDetails-&gt;social-&gt;imageUrl;\r\n\r\n   \t \r\n\r\n   \t\t\t } else if ($type == &quot;subscription&quot;) {\r\n\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#video&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;subscription-&gt;resourceId-&gt;videoId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#channel&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Channel id &quot; .$item-&gt;contentDetails-&gt;subscription-&gt;resourceId-&gt;channelId;\r\n   \t\t\t\t }\r\n   \t\t\t\t if ($activityKind == &quot;YouTube#playlist&quot;) {\r\n   \t\t\t\t\t $activityInfo .= &quot;&lt;br&gt;Playlist id &quot; .$item-&gt;contentDetails-&gt;subscription-&gt;resourceId-&gt;playlistId;\r\n   \t\t\t\t }\r\n\r\n\r\n   \t\t\t } else if ($type == &quot;upload&quot;) {\r\n   \t\t\t\t $activityKind = $item-&gt;contentDetails-&gt;upload-&gt;resourceId-&gt;kind;\r\n   \t\t\t\t \r\n   \t\t\t\t $activityInfo .= &quot;&lt;br&gt;Video id &quot; .$item-&gt;contentDetails-&gt;upload-&gt;videoId;\r\n\r\n\r\n   \t\t\t }\r\n\r\n   \t\t\t echo(&quot;Date:&quot; . $publishedAt . &quot;, Channel Id:&quot; . $channelId . &quot; &quot; . $title . &quot;&lt;br&gt;&quot;);\r\n   \t\t\t echo(&quot;Activity Type:&quot; . $type . &quot;&lt;br&gt;&quot;);\r\n   \t\t\t echo(&quot;Kind: &quot; . $activityKind . &quot;&lt;br&gt;&quot;);\r\n   \t\t\t echo($activityInfo);\r\n   \t\t\t echo(&quot;&lt;hr&gt;&quot;);\r\n\r\n   \t\t } \/\/ foreach\r\n   \t } \/\/ if resp\r\n\r\n\r\n   \t \r\n    \r\n?&gt;\r\n<\/pre><\/p>\n<p>The API URL will have the parameter \u201cmine=true\u201d instead of \u201cchannelId=xx\u201d. The output will be similar to that of Channel activities:<\/p>\n<pre><span style=\"color: #999999;\">JSON decoded<\/span>\r\n\r\n<span style=\"color: #999999;\">Date:2017-05-18T05:18:16.000Z, Channel Id:UCnXmfpAZ1rLsg0Goh0bBHUA Peggy Rometo's Weekly Wake Up For 5-14-17<\/span>\r\n<span style=\"color: #999999;\">Activity Type:like<\/span>\r\n<span style=\"color: #999999;\">Kind: YouTube#video<\/span>\r\n\r\n<span style=\"color: #999999;\">Video id PTH0aANxYEM<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-15T08:31:41.000Z, Channel Id:UCnXmfpAZ1rLsg0Goh0bBHUA PISCES MAY 15,2017 WEEKLY HOROSCOPES BY MARIE MOORE<\/span>\r\n<span style=\"color: #999999;\">Activity Type:like<\/span>\r\n<span style=\"color: #999999;\">Kind: YouTube#video<\/span>\r\n\r\n\r\n<span style=\"color: #999999;\">Video id yddQLZLfVrg<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-14T04:34:21.000Z, Channel Id:UCnXmfpAZ1rLsg0Goh0bBHUA PISCES May 2017 Extended Monthly Tarot Reading | Intuitive Tarot by Nicholas<\/span>\r\n<span style=\"color: #999999;\">Activity Type:like<\/span>\r\n<span style=\"color: #999999;\">Kind: YouTube#video<\/span>\r\n\r\n<span style=\"color: #999999;\">Video id 0bVxFk1Ap0c<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-11T17:44:46.000Z, Channel Id:UCnXmfpAZ1rLsg0Goh0bBHUA 05 Mads langer - Overgir mig langsomt.<\/span>\r\n<span style=\"color: #999999;\">Activity Type:playlistItem<\/span>\r\n<span style=\"color: #999999;\">Kind: YouTube#video<\/span>\r\n\r\n\r\n<span style=\"color: #999999;\">Video id XnCYP8rGUqY<\/span>\r\n<span style=\"color: #999999;\">Date:2017-05-07T12:51:24.000Z, Channel Id:UCnXmfpAZ1rLsg0Goh0bBHUA Shayne Ward - No Promises<\/span>\r\n<span style=\"color: #999999;\">Activity Type:playlistItem<\/span>\r\n<span style=\"color: #999999;\">Kind: YouTube#video<\/span>\r\n\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>This is article 8 of the YouTube API With PHP series. We will see how to work with YouTube Activities. An Activity is any task <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2017\/06\/21\/8-youtube-data-api-activities-list-function\/\" title=\"8 &#8211; YouTube Data API &#8211; Activities &#8211; list function\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2727,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[318],"tags":[],"class_list":["post-2811","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-youtube-api-with-php"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2811"}],"version-history":[{"count":3,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2811\/revisions"}],"predecessor-version":[{"id":2815,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2811\/revisions\/2815"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2727"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=2811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=2811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}