I am trying to get the number of emails (read & unread shown separately) for a given search. I've read that the labels.get() function does the trick but I don't know how to use it. Here's the code I have to detect if I have less or more than 100 result for a given sender.
require_once '../../vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('../../client_secrets.json');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
$client->addScope(Google_Service_Gmail::GMAIL_READONLY);
$client->setAccessType("offline");
$client->setApprovalPrompt('force');
$client->setAccessToken($_SESSION['token']);
$service = new Google_Service_Gmail($client);
$sender = array();
$sender[] = 'sender1#email.com';
$sender[] = 'sender2#email.com';
$sender[] = 'sender3#email.com';
function countfrom($service, $userId, $expeditor) {
try
{
unset($optParamsamz);
$optParamsamz = [];
$optParamsamz['maxResults'] = 100; // Return Only 5 Messages
$optParamsamz['q'] = "From: '".$expeditor."' ";
$messagesamz = $service->users_messages->listUsersMessages('me',$optParamsamz);
$listamz = $messagesamz->getMessages();
echo sizeof($listamz);
}
catch (Exception $e)
{
print 'An error occurred: ' . $e->getMessage();
}
}
foreach ($sender as $key => $value)
{
echo $value .': ';
countfrom($service,$_SESSION['emaile'],$value) ;
echo '<br/>';
}
------------------- EDIT ----------------------
I have tried a new solution that seems closer to what I'm looking for. The issue now comes from Google who returns some odd number for the resultestimatsize:
<?
require_once '../../vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('../../client_secrets.json');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);
$client->addScope(Google_Service_Gmail::GMAIL_READONLY);
$client->setAccessType("offline");
$client->setApprovalPrompt('force');
$client->setAccessToken($_SESSION['token']);
$service = new Google_Service_Gmail($client);
$sender_array[] = 'sender1#sender.com';
$sender_array[] = 'sender2#sender.com';
$sender_array[] = 'sender3#sender.com';
$sender_array[] = 'sender4#sender.com';
foreach ($sender_array as $key => $expeditor)
{
$optParamsamz1['q'] = "From: '".$expeditor."' is:read ";
$optParamsamz2['q'] = "From: '".$expeditor."' ";
echo $expeditor.": ".$service->users_messages->listUsersMessages('me',$optParamsamz1)->getResultSizeEstimate() . "
".$service->users_messages->listUsersMessages('me',$optParamsamz2)->getResultSizeEstimate();
echo "<br>";
}
?>
labels.get() will be of no help in this use case, I'm afraid. It only works for labels, so you could get read/unread from e.g. INBOX or CHAT easily, but will be of no help if you want to get all read/unread from e.g. all messages sent from example#gmail.com.
An alternative solution is fairly cheap though:
List messages with the query + AND is:unread, and a second one with the same query +
AND -is:unread.
If the response contains a nextPageToken, you have 100+ read/unread. If it does not contain a nextPageToken, there are response.messages.length amount of read/unread messages.
Example
Request unread
q = from:info#berniesanders.com AND is:unread
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=from%3Ainfo%40berniesanders.com+AND+is%3Aunread&access_token={YOUR_API_KEY}
Response
{
"messages": [
{
"id": "1523144d6e3feb2e",
"threadId": "1523144d6e3feb2e"
},
{
"id": "15227d879ccb601f",
"threadId": "15227d879ccb601f"
}, ...
}
// No nextPageToken => response.messages.length unread = 22 unread
Request NOT unread
q = from:info#berniesanders.com AND -is:unread
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=from%3Ainfo%40berniesanders.com+AND+-is%3Aunread&access_token={YOUR_API_KEY}
Response
{
"messages": [
{
"id": "1522d4af39d7eec6",
"threadId": "1522d4af39d7eec6"
},
{
"id": "1521d6f3dbeaf886",
"threadId": "1521d6f3dbeaf886"
}, ...
"nextPageToken": "32436546446"
}
// nextPageToken in response => 100+ read
You could take it one step further and keep on listing with the nextPageToken until there is no nextPageToken in the response, and just add all the results together, but that might be to slow or inefficient for your use case.
Related
This code sometimes works, but frequently runs for ~20s then fails with the "503 Service Unavailable" message when I call getPage(). The authentication/token request seems to be working fine.
I can't seem to identify any pattern of when it fails/succeeds. I don't believe it's a throttling error, as there is no "Retry-After" header returned, and the script only runs once per day at night with <200 records returned. I've also tried removing the $filter and changing parameter order as described here, with no clear benefit.
Can someone please help find the cause here? Happy to share any additional info. Any help is much appreciated, thanks!
<?php
define('DEBUG', true);
session_start();
// set config vars
$ms_url_base = "https://login.microsoftonline.com/d3523db7-f84a-4a24-a815-cd4ba4691c9c";
$ms_client_id = '<client id>';
$ms_redirect_uri = "https://example.com/path";
$ms_scope = "calendars.readwrite user.read";
$ms_client_secret = '<secret>';
$ms_auth_endpoint = '/oauth2/v2.0/authorize';
$ms_token_endpoint = '/oauth2/v2.0/token';
$query_numdays = 100;
if (DEBUG) error_reporting(E_ALL);
date_default_timezone_set("America/Detroit");
require_once __DIR__.'/vendor/autoload.php';
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
class EventMod extends \Microsoft\Graph\Model\Event {
// custom functions here
public function getNextLink() {
parent::getNextLink();
}
}
class ResponseMod extends \Microsoft\Graph\Http\GraphResponse {}
// authorization
$provider = new Stevenmaguire\OAuth2\Client\Provider\Microsoft([
'clientId' => $ms_client_id,
'clientSecret' => $ms_client_secret,
'redirectUri' => $ms_redirect_uri,
'urlAuthorize' => $ms_url_base.$ms_auth_endpoint,
'urlAccessToken' => $ms_url_base.$ms_token_endpoint,
'urlResourceOwnerDetails' => 'https://graph.microsoft.com/v2.0/me',
]);
if (!isset($_GET['code'])) {
$options = ['scope' => $ms_scope, 'aud' => 'Graph'];
$authUrl = $provider->getAuthorizationUrl($options);
$_SESSION['oauth2state'] = $provider->getState();
header('Location: '.$authUrl);
exit;
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
unset($_SESSION['oauth2state']);
exit('Invalid state');
} else {
try {
$token = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
} catch (League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
exit ("Get access token exception: ".$e->getMessage());
}
if (DEBUG) {
echo 'Access Token: ' . $token->getToken() . "<p>";
echo 'Refresh Token: ' . $token->getRefreshToken() . "<p>";
echo 'Expired in: ' . $token->getExpires() . "<p>";
echo 'Already expired? ' . ($token->hasExpired() ? 'expired' : 'not expired') . "<p>";
}
// start calendar query
$start=new DateTimeImmutable("yesterday 0:0:1");
$end = $start->add(new DateInterval("P".$query_numdays."D"));
$url='/me/calendarview'
.'?startdatetime='.$start->format('c')
.'&enddatetime='.$end->format('c')
.'&$filter=isOrganizer+eq+false'
.'&$select=subject,responseStatus,start,categories'
.'&$orderby=start/dateTime';
$graph = new Graph;
$graph->setAccessToken($token->getToken());
$data = array();
try {
$iterator = $graph->createCollectionRequest("GET", $url)
->setReturnType(EventMod::class)
->addHeaders(["Prefer" => 'outlook.timezone="America/Detroit"'])
->setPageSize(25);
do {
$page = $iterator->getPage(); /*************** THIS IS WHERE THE EXCEPTION HAPPENS ************/
if (DEBUG) echo "<pre>".print_r($page, true)."</pre>";
$data = array_merge($data, $page);
} while (!$iterator->isEnd());
}
catch (\Microsoft\Graph\Exception\GraphException $e) {
if (DEBUG) echo "GraphException Message: ".$e->getMessage();
exit;
}
catch (Exception $e) {
if (DEBUG) echo "Unk Exception getting data: ".$e->getMessage();
exit;
}
if (DEBUG) print_r($data);
}
?>
composer.json
{
"require": {
"microsoft/microsoft-graph": "^1.29",
"stevenmaguire/oauth2-microsoft": "^2.2"
}
}
I played with your above API call and i ended up noticing the issue - in the case of having bigger larger dates and lot of data at my end (not with smaller time window or less records). It tells me that the failure is due to the client timeout. We need to understand that Calendar view is an expensive operation that too when you deal with calendars and filters added to it. So i went ahead in this scenario, reduce/minimize time window for calendar view by client so smaller segments of time are scanned for matching calendar events. It helped me to get the records as i expected and make use of effective usage of Calendarview API call too.
Apparently the issue was not in the code at all. I discovered that the 503 error was thrown only when a specific date's events were being read by the API. One of the events was rather large and I deleted it; after this the script works well.
This particular event has 16536 attendees listed, which I believe was the source of the error. Still unexplained is why the error was intermittent. I was eventually able to get graph explorer to successfully read the event, so perhaps the bug is in the Microsoft Graph SDK for PHP. I will post there to see if the devs want to capture this error condition.
I am working customer relationship department and creating an app which is replying to every YouTube comment.
So what i am making right now is basically a script which pull comment data from YouTube Data API v3. This script is a looping script which is being called every 30 seconds, however you may know the YouTube API has a quota limit and I keep hitting it.
I am open for any solution:
Do I have to apply for more quota to YouTube
How much quota should i apply ( basically im only pulling comment data, from who, id , and timestamp ) or sis there any other way.
my code
<?php
if (!file_exists(__DIR__ . '/youtube_vendor/autoload.php')) {
throw new Exception(sprintf('Please run "composer require google/apiclient:~2.0" in "%s"', __DIR__));
}
require_once __DIR__ . '/youtube_vendor/autoload.php';
include "mysql.php";
$db = new db();
$client = new Google_Client();
$client->setAuthConfig('client_secret.json');
$client->addScope('https://www.googleapis.com/auth/youtube.readonly');
$client->addScope('https://www.googleapis.com/auth/youtube.force-ssl');
$client->setRedirectUri('your_url');
// offline access will give you both an access and refresh token so that
// your app can refresh the access token without user interaction.
$client->setAccessType('offline');
// Using "consent" ensures that your application always receives a refresh token.
// If you are not using offline access, you can omit this.
$client->setPrompt("consent");
$client->setIncludeGrantedScopes(true); // incremental auth
$auth_url = $client->createAuthUrl();
if(isset($_GET['code'])) {
// id index exists
$client->authenticate($_GET['code']);
$access_token = $client->getAccessToken();
// var_dump($access_token);
// echo "<br><br>";
// file_put_contents("received.txt",var_dump($access_token));
// $access_token = file_get_contents("received.txt");
// // $file = json_decode($fb);
// var_dump($access_token);
// serialize your input array (say $array)
$serializedData = serialize($access_token);
// save serialized data in a text file
file_put_contents('youtube_access_token.txt', $serializedData);
// at a later point, you can convert it back to array like:
$recoveredData = file_get_contents('youtube_access_token.txt');
// unserializing to get actual array
$access_token = unserialize($recoveredData);
// you can print your array like
print_r($access_token);
echo "<br>";
$client->setAccessToken($access_token);
$service = new Google_Service_YouTube($client);
// $channel = $youtube->channels->listChannels('snippet', array('mine' => $mine));
// var_dump($channel);
$queryParams = [
'maxResults' => 25,
'mine' => true
];
$arrayComment = array();
$arrayReplies = array();
$responseVideo = $service->activities->listActivities('snippet,contentDetails', $queryParams);
foreach($responseVideo['items'] as $video)
{
$db->insert_youtube_video($video['snippet']['channelId'],$video['snippet']['channelTitle'],$video['snippet']['publishedAt'],$video['snippet']['title'],$video['snippet']['description'],$video['snippet']['thumbnails']['standard']['url'],$video['contentDetails']['upload']['videoId']);
$queryParams = [
'videoId' => $video['contentDetails']['upload']['videoId']
];
$responseComment = $service->commentThreads->listCommentThreads('snippet,replies', $queryParams);
foreach($responseComment['items'] as $comment)
{
$db->insert_youtube_comment($comment['snippet']['topLevelComment']['snippet']['authorChannelUrl'],$comment['snippet']['topLevelComment']['snippet']['authorDisplayName'],$comment['snippet']['topLevelComment']['snippet']['authorProfileImageUrl'],$comment['snippet']['topLevelComment']['snippet']['publishedAt'],$comment['snippet']['topLevelComment']['snippet']['updatedAt'],$comment['snippet']['topLevelComment']['snippet']['textDisplay'],$comment['snippet']['topLevelComment']['snippet']['videoId'],$comment['snippet']['topLevelComment']['id']);
$queryParams = [
'parentId' => $comment['snippet']['topLevelComment']['id']
];
$responseReplies = $service->comments->listComments('snippet', $queryParams);
foreach ($responseReplies['items'] as $replies)
{
$db->insert_youtube_replies($replies['snippet']['authorChannelUrl'],$replies['snippet']['authorDisplayName'],$replies['snippet']['authorProfileImageUrl'],$replies['snippet']['publishedAt'],$replies['snippet']['updatedAt'],$replies['snippet']['textDisplay'],$replies['snippet']['videoId'],$comment['snippet']['topLevelComment']['id'],$replies['id']);
}
$arrayReplies[] = $responseReplies;
}
$arrayComment[] = $responseComment;
}
}
else
{
echo $auth_url;
}
?>
<textarea style="width:100%;height:300px"><?php print_r($responseVideo['items']); ?><?php print_r($arrayComment); ?><?php print_r($arrayReplies); ?></textarea>
<script>
setTimeout(function () { window.location.reload(); }, 15*1000);
document.write(new Date());
</script>
Do I have to apply for more quota to YouTube
if you want to avoid hitting the quota and continue to make the number of requests you are making now. Yes you need to apply for a quota extension.
I would apply as soon as possible it can take a long time to get an extension.
How much quota should i apply ( basically im only pulling comment data, from who, id , and timestamp ) or sis there any other way.
That is up to you. How many requests are you making every day. You will need to do some math then pad it to ensure for future in crease of your application.
I am working on a project where I have several labels associated with every email. I want to remove the labels using gmail PHP API. I have followed the documentation and I have done all the steps. But, I do not know why I get Error, when I try to remove the label.
This is the code that is associated with the project. Please help me with any thoughts.
$client_id = 'aoppedisano#tecnavi.com';
$service_account_name = 'anthony#teak-truck- 130612.iam.gserviceaccount.com';
$key_file_location = 'anthony.p12';
$userid_from='aoppedisano#tecnavi.com';
$client = new Google_Client();
var_dump($client);
$client->setScopes(array('https://www.googleapis.com/auth/gmail.modify'));
$client->setApplicationName("Client_Library_Examples");
if (isset($_SESSION['service_token'])) {
$client->setAccessToken($_SESSION['service_token']);
}
$key = file_get_contents($key_file_location);
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
array(
/*
'https://www.googleapis.com/auth/gmail.send',
'https://www.googleapis.com/auth/gmail.compose',
'https://www.googleapis.com/auth/gmail.modify',
*/
'https://www.googleapis.com/auth/gmail.readonly'
),
$key
);
//var_dump($cred);
$cred->sub=$userid_from; //<-- Important!
$client->setAssertionCredentials($cred);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$service = new Google_Service_Gmail($client);
$messageId=$_REQUEST["id"];
$userId = 'me';
$optParamsGet = [];
$optParamsGet['format'] = 'full';
$message = $service->users_messages->get('me',$messageId,$optParamsGet);
$labelsToRemove=$_REQUEST['label'];
$labelsToAdd=[];
$message=modifyMessage($service,$userId, $messageId, $labelsToAdd, $labelsToRemove);
function modifyMessage($service, $userId, $messageId, $labelsToAdd, $labelsToRemove) {
$mods = new Google_Service_Gmail_ModifyMessageRequest();
$mods->setAddLabelIds($labelsToAdd);
$mods->setRemoveLabelIds($labelsToRemove);
try {
$message = $service->users_messages->modify($userId, $messageId, $mods);
print 'Message with ID: ' . $messageId . ' successfully modified.';
return $message;
} catch (Exception $e) {
print 'An error occurred: ' . $e->getMessage();
}
}
As given in Standard Error Responses for Google APIs, 403: insufficientPermissions error code means that the authenticated user does not have sufficient permissions to execute this request.
To delete labels, you should have this scope code in your permissions:
https://www.googleapis.com/auth/gmail.labels
For more details about scopes, please go through Choose Auth Scopes.
I'm trying to authenticate on Bing Ads Api but I'm getting this message:
Authentication failed. Either supplied credentials are invalid or the account is inactive
This is my code:
$UserName = "xxx#hotmail.com";
$Password = "xxx";
$DeveloperToken = "xxx";
$CustomerId = xxx;
$AccountId = xxx;
$wsdl = "https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V10/CampaignManagementService.svc?singleWsdl";
try
{
$proxy = ClientProxy::ConstructWithAccountAndCustomerId($wsdl, $UserName, $Password, $DeveloperToken, $AccountId, $CustomerId, null);
// Specify one or more campaigns.
$campaigns = array();
$campaign = new Campaign();
$campaign->Name = "Winter Clothing " . $_SERVER['REQUEST_TIME'];
$campaign->Description = "Winter clothing line.";
$campaign->BudgetType = BudgetLimitType::MonthlyBudgetSpendUntilDepleted;
$campaign->MonthlyBudget = 1000.00;
$campaign->TimeZone = "PacificTimeUSCanadaTijuana";
$campaign->DaylightSaving = true;
// Used with FinalUrls shown in the ads that we will add below.
$campaign->TrackingUrlTemplate =
"http://tracker.example.com/?season={_season}&promocode={_promocode}&u={lpurl}";
$campaigns[] = $campaign;
// Add the campaign, ad group, keywords, and ads
$campaignIds = AddCampaigns($proxy, $AccountId, $campaigns);
PrintCampaignIdentifiers($campaignIds);
}
catch (SoapFault $e)
{
// Output the last request/response.
print "\nLast SOAP request/response:\n";
print $proxy->GetWsdl() . "\n";
print $proxy->GetService()->__getLastRequest()."\n";
print $proxy->GetService()->__getLastResponse()."\n";
// Campaign Management service operations can throw AdApiFaultDetail.
if (isset($e->detail->AdApiFaultDetail))
{
// Log this fault.
print "The operation failed with the following faults:\n";
$errors = is_array($e->detail->AdApiFaultDetail->Errors->AdApiError)
? $e->detail->AdApiFaultDetail->Errors->AdApiError
: array('AdApiError' => $e->detail->AdApiFaultDetail->Errors->AdApiError);
// If the AdApiError array is not null, the following are examples of error codes that may be found.
foreach ($errors as $error)
{
print "AdApiError\n";
printf("Code: %d\nError Code: %s\nMessage: %s\n", $error->Code, $error->ErrorCode, $error->Message);
switch ($error->Code)
{
case 105: // InvalidCredentials
break;
case 117: // CallRateExceeded
break;
default:
print "Please see MSDN documentation for more details about the error code output above.\n";
break;
}
}
Sorry for the delayed reply. I noticed that you are setting the UserName to ***#hotmail.com. If you are using an email address login i.e. Microsoft account, then you must use OAuth i.e. set the AuthenticationToken header element instead of setting the UserName/Password fields.
I would like to know how to get the total number of channel views. I've been searching all over the youtube API, but can't seem to find one.
Your help will be greatly appreciated.
Thanks! :)
You need to use Channel.list of the API. The total view of a channel is in the part statistics.
You need the channel name or the channel id. If you want the channel id but you only have the channel name, you can use this app to get the YouTube Id of the channel.
The result form is :
{
"kind": "youtube#channelListResponse",
"etag": "\"gMjDJfS6nsym0T-NKCXALC_u_rM/0FiX4yi2JggRgndNH8LVUqGkBEs\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"gMjDJfS6nsym0T-NKCXALC_u_rM/ch89JvwOeEbWio2fOHY7sxE7XCc\"",
"id": "UCMGgBRBiijmpgL3xNuiDVOQ",
"statistics": {
"viewCount": "5861117",
"commentCount": "275",
"subscriberCount": "40674",
"hiddenSubscriberCount": false,
"videoCount": "29"
}
}
]
}
The total view of the channel is in the part [items"][0]["statistics"]["viewCount"]
For this channel, the viewCount is : 5 861 117, the same number if you look at the channel https://www.youtube.com/user/Vecci87/about.
LIVE EXAMPLE
EDIT
You can use Youtube API Analytics. Important information, you need to be the owner of the YouTube Account, this method requires authenfification with Oauth2.
I made you a basic example, I define two date : today and a past day. I set the metrics to view and a dimension to day, to have the view for each days.
Finally i add all this values.
$today = date("Y-m-d");
$datePast = date('Y-m-d', strtotime("-".$period." day"));
try {
$activitiesView = $youtube->reports->query('channel=='.$idde.'', $datePast , $today, 'views', array('dimensions' => 'day'));
} catch(Google_ServiceException $e) { }
$average = 0;
if(isset($activitiesView['rows'])) {
foreach ($activitiesView['rows'] as $value) {
$average += $value[1];
}
$average = $average/count($activitiesView['rows']);
}
Full code example :
<?php
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_YouTubeAnalyticsService.php';
require_once 'google-api-php-client/src/contrib/Google_Oauth2Service.php';
// Set your cached access token. Remember to replace $_SESSION with a
// real database or memcached.
session_start();
$client = new Google_Client();
$client->setApplicationName('Google+ PHP Starter Application');
$client->setClientId('YOUR_CLIENT_ID');
$client->setClientSecret('CLIENT_SECRET');
$client->setRedirectUri('REDIRECT_URI');
$client->setDeveloperKey('YOUR_DEV_KEY');
$youtube = new Google_YouTubeAnalyticsService($client);
$service = new Google_YouTubeService($client);
$auth2 = new Google_Oauth2Service($client);
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if ($client->getAccessToken()) {
/***************USER STATS********************/
$today = date("Y-m-d");
$datePast = date('Y-m-d', strtotime("-".$period." day"));
try {
$activitiesView = $youtube->reports->query('channel=='.$idde.'', $datePast , $today, 'views', array('dimensions' => 'day'));
} catch(Google_ServiceException $e) { }
$average = 0;
if(isset($activitiesView['rows'])) {
foreach ($activitiesView['rows'] as $value) {
$average += $value[1];
}
$average = $average/count($activitiesView['rows']);
}
/***************USER STATS********************/
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
//simple verification
if(strpos($RedirectUri, "redirect_uri") !== false) {
header('Location: error.php');
exit;
}
}
Go to the Following URL
https://developers.google.com/youtube/v3/docs/channels/list
Use the API Explorer to call this method on live data and see the API request and response
Execute the API and see the response
View the Statistics Section there you can find the information what you are looking for
This link provides the youtube channel report in range. But when used with google php library it get hooked in a "User login required Error!"
https://developers.google.com/apis-explorer/#p/youtubeAnalytics/v1/youtubeAnalytics.reports.query?ids=channel%253D%253DMINE&start-date=2014-05-01&end-date=2014-06-30&metrics=views&dimensions=day&_h=3&
Is there any way i can access the channel analytics report in youtube V3 same as like in v3
http://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=statistics&id=UCMGgBRBiijmpgL3xNuiDVOQ&_h=10&