Skip to content

Instantly share code, notes, and snippets.

@tszym
tszym / youtube-data.php
Created July 3, 2014 10:03
Youtube Data API v3 - Authentication
<?php
/**
* How to authenticate with OAuth2 by the Google API client
**/
$classLoader = require __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../vendor/google/apiclient/src/Google/Client.php';
require_once __DIR__.'/../vendor/google/apiclient/src/Google/Service/YouTube.php';
@tszym
tszym / youtube-analytics.php
Created July 3, 2014 09:24
Youtube Analytics API - Get metrics
<?php
// ...
if ($client->getAccessToken()) {
// Create analytics service object.
$youtube = new Google_Service_YouTubeAnalytics($client);
try {
// Here we query the API
$analyticsResponse = $youtube->reports->query('channel==UCKVMqeVtKOKxIIqPX84_MKA', '2014-06-25', '2014-06-29',
@tszym
tszym / youtube-analytics.php
Created July 3, 2014 08:38
Youtube Analytics API - Authentication
<?php
/**
* How to authenticate with OAuth2 by the Google API client
**/
$classLoader = require __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../vendor/google/apiclient/src/Google/Client.php';
require_once __DIR__.'/../vendor/google/apiclient/src/Google/Service/YouTubeAnalytics.php';