use of com.google.api.services.youtubereporting.YouTubeReporting in project api-samples by youtube.
the class CreateReportingJob method main.
/**
* Create a reporting job.
*
* @param args command line args (not used).
*/
public static void main(String[] args) {
/*
* This OAuth 2.0 access scope allows for read access to the YouTube Analytics monetary reports for
* authenticated user's account. Any request that retrieves earnings or ad performance metrics must
* use this scope.
*/
List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/yt-analytics-monetary.readonly");
try {
// Authorize the request.
Credential credential = Auth.authorize(scopes, "createreportingjob");
// This object is used to make YouTube Reporting API requests.
youtubeReporting = new YouTubeReporting.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential).setApplicationName("youtube-cmdline-createreportingjob-sample").build();
// Prompt the user to specify the name of the job to be created.
String name = getNameFromUser();
if (listReportTypes()) {
createReportingJob(getReportTypeIdFromUser(), name);
}
} catch (GoogleJsonResponseException e) {
System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage());
e.printStackTrace();
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
e.printStackTrace();
} catch (Throwable t) {
System.err.println("Throwable: " + t.getMessage());
t.printStackTrace();
}
}
use of com.google.api.services.youtubereporting.YouTubeReporting in project api-samples by youtube.
the class RetrieveReports method main.
/**
* Retrieve reports.
*
* @param args command line args (not used).
*/
public static void main(String[] args) {
/*
* This OAuth 2.0 access scope allows for read access to the YouTube Analytics monetary reports for
* authenticated user's account. Any request that retrieves earnings or ad performance metrics must
* use this scope.
*/
List<String> scopes = Lists.newArrayList("https://www.googleapis.com/auth/yt-analytics-monetary.readonly");
try {
// Authorize the request.
Credential credential = Auth.authorize(scopes, "retrievereports");
// This object is used to make YouTube Reporting API requests.
youtubeReporting = new YouTubeReporting.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential).setApplicationName("youtube-cmdline-retrievereports-sample").build();
if (listReportingJobs()) {
if (retrieveReports(getJobIdFromUser())) {
downloadReport(getReportUrlFromUser());
}
}
} catch (GoogleJsonResponseException e) {
System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage());
e.printStackTrace();
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
e.printStackTrace();
} catch (Throwable t) {
System.err.println("Throwable: " + t.getMessage());
t.printStackTrace();
}
}
Aggregations