Check the documentation here
package com.google.api.services.samples.youtube.cmdline.youtube_cmdline_channelbulletin_sample; import java.io.File; import java.util.Calendar; import java.util.List; import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; import com.google.api.client.extensions.java6.auth.oauth2.FileCredentialStore; import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; import com.google.api.client.googleapis.json.GoogleJsonResponseException; import com.google.api.client.http.HttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.services.youtube.YouTube; import com.google.api.services.youtube.model.Activity; import com.google.api.services.youtube.model.ActivityContentDetails; import com.google.api.services.youtube.model.ActivityContentDetails.Bulletin; import com.google.api.services.youtube.model.ActivitySnippet; import com.google.api.services.youtube.model.Channel; import com.google.api.services.youtube.model.ChannelListResponse; import com.google.api.services.youtube.model.ResourceId; import com.google.common.collect.Lists; /** * Creates a video bulletin that is posted to the user's channel feed. * * @author Jeremy Walker */ public class ChannelBulletin { /** Global instance of the HTTP transport. */ private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport(); /** Global instance of the JSON factory. */ private static final JsonFactory JSON_FACTORY = new JacksonFactory(); /** Global instance of YouTube object to make all API requests. */ private static YouTube youtube; /* * Global instance of the video id we want to post as a bulletin into our channel feed. You will * probably pull this from a search or your app. */ private static String VIDEO_ID = "L-oNKK1CrnU"; /** * Authorizes the installed application to access user's protected data. * * @param scopes list of scopes needed to run upload. */ private static Credential authorize(Listscopes) throws Exception { // Load client secrets. GoogleClientSecrets clientSecrets = GoogleClientSecrets.load( JSON_FACTORY, ChannelBulletin.class.getResourceAsStream("/client_secrets.json")); // Checks that the defaults have been replaced (Default = "Enter X here"). if (clientSecrets.getDetails().getClientId().startsWith("Enter") || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) { System.out.println( "Enter Client ID and Secret from https://code.google.com/apis/console/?api=youtube" + "into youtube-cmdline-channelbulletin-sample/src/main/resources/client_secrets.json"); System.exit(1); } // Set up file credential store. FileCredentialStore credentialStore = new FileCredentialStore( new File(System.getProperty("user.home"), ".credentials/youtube-api-channelbulletin.json"), JSON_FACTORY); // Set up authorization code flow. GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder( HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, scopes).setCredentialStore(credentialStore) .build(); // Build the local server and bind it to port 8080 LocalServerReceiver localReceiver = new LocalServerReceiver.Builder().setPort(8080).build(); // Authorize. return new AuthorizationCodeInstalledApp(flow, localReceiver).authorize("user"); } /** * Authorizes user, runs Youtube.Channnels.List to get the default channel, and posts a bulletin * with a video id to the user's default channel. * * @param args command line args (not used). */ public static void main(String[] args) { // Scope required to upload to YouTube. List scopes = Lists.newArrayList("https://www.googleapis.com/auth/youtube"); try { // Authorization. Credential credential = authorize(scopes); // YouTube object used to make all API requests. youtube = new YouTube.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName( "youtube-cmdline-channelbulletin-sample").build(); /* * Now that the user is authenticated, the app makes a channel list request to get the * authenticated user's channel. https://developers.google.com/youtube/v3/docs/channels/list */ YouTube.Channels.List channelRequest = youtube.channels().list("contentDetails"); channelRequest.setMine("true"); /* * Limits the results to only the data we need making your app more efficient. */ channelRequest.setFields("items/contentDetails"); ChannelListResponse channelResult = channelRequest.execute(); /* * Gets the list of channels associated with the user. */ List channelsList = channelResult.getItems(); if (channelsList != null) { // Gets user's default channel id (first channel in list). String channelId = channelsList.get(0).getId(); /* * We create the snippet to set the channel we will post to and the description that goes * along with our bulletin. */ ActivitySnippet snippet = new ActivitySnippet(); snippet.setChannelId(channelId); Calendar cal = Calendar.getInstance(); snippet.setDescription("Bulletin test video via YouTube API on " + cal.getTime()); /* * We set the kind of the ResourceId to video (youtube#video). Please note, you could set * the type to a playlist (youtube#playlist) and use a playlist id instead of a video id. */ ResourceId resource = new ResourceId(); resource.setKind("youtube#video"); resource.setVideoId(VIDEO_ID); Bulletin bulletin = new Bulletin(); bulletin.setResourceId(resource); // We construct the ActivityContentDetails now that we have the Bulletin. ActivityContentDetails contentDetails = new ActivityContentDetails(); contentDetails.setBulletin(bulletin); /* * Finally, we construct the activity we will write to YouTube via the API. We set the * snippet (covers description and channel we are posting to) and the content details * (covers video id and type). */ Activity activity = new Activity(); activity.setSnippet(snippet); activity.setContentDetails(contentDetails); /* * We specify the parts (contentDetails and snippet) we will write to YouTube. Those also * cover the parts that are returned. */ YouTube.Activities.Insert insertActivities = youtube.activities().insert("contentDetails,snippet", activity); // This returns the Activity that was added to the user's YouTube channel. Activity newActivityInserted = insertActivities.execute(); if (newActivityInserted != null) { System.out.println( "New Activity inserted of type " + newActivityInserted.getSnippet().getType()); System.out.println(" - Video id " + newActivityInserted.getContentDetails().getBulletin().getResourceId().getVideoId()); System.out.println( " - Description: " + newActivityInserted.getSnippet().getDescription()); System.out.println(" - Posted on " + newActivityInserted.getSnippet().getPublishedAt()); } else { System.out.println("Activity failed."); } } else { System.out.println("No channels are assigned to this user."); } } catch (GoogleJsonResponseException e) { e.printStackTrace(); System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } catch (Throwable t) { t.printStackTrace(); } } }
60 comments :
Awesome documentation on Java Training in Chennai YouTube Data API - Java Online Course Java Code Samples
Got a creative information. Understand well in this. This gives the easy technique of experiment. New technologies are developed more. so techniques are also improved. Thank you for this information.
Java Training in Chennai
Thanks for the information. Helped us to convince most on how this process works and what they could achieve by following these guidelinese commerce website design and development
Useful post. Happy to visit your blog. Thanks for sharing.
web design courses in chennai
Wow! great article. Glad to find your blog. Thanks for sharing.
website design training in chennai
Amazing article..
SAP Training in Chennai | SAP Training Institutes in Chennai | Best SAP Training in Chennai
Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
Regards,
PMP Training | PMP Training in Chennai
Useful info and nice article, glad to read and understand about this article.
Java Training in chennai
Interesting and informative article.. very useful to me.. thanks for sharing your wonderful ideas.. please keep on updating.
Software Testing Training in chennai | Android Training in chennai
very interesting post.. thanks to sharing me..
PHP Training Institute in Chennai
Java Training Institutes Java Training Institutes Java EE Training in Chennai Java EE Training in Chennai Java Spring Hibernate Training Institutes in Chennai J2EE Training Institutes in Chennai J2EE Training Institutes in Chennai Core Java Training Institutes in Chennai Core Java Training Institutes in Chennai
Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training
Yo, it seems for me that its a little bit complicated solution, especially for beginners. Why do we need do all this things, if we can just use this amazing widget https://elfsight.com/youtube-channel-plugin-yottie/ that will be understandable even for a child?
This is my 1st visit to your web... But I'm so impressed with your content. Good Job!
python training in chennai | python training in chennai | python training in bangalore
Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
Data Science training in kalyan nagar
Data Science training in OMR | Data science training in chennai
Data Science training in chennai | Best Data science Training in Chennai
Data science training in velachery | Data Science Training in Chennai
Data science training in tambaram | Data Science training in Chennai
Data science training in jaya nagar | Data science Training in Bangalore
Your post is really awesome. Your blog is really helpful for me to develop my skills in a right way. Thanks for sharing this unique information with us.
- Digital marketing courses in Bangalore
All the points you described so beautiful. Every time i read your i blog and i am so surprised that how you can write so well.
Selenium training in Chennai | Selenium training institute in Chennai | Selenium course in Chennai
Selenium training in Bangalore | Selenium training institute in Bangalore | Selenium course in Bangalore
Selenium interview questions and answers
Selenium training in Pune | Selenium training institute in Pune | Selenium course in Pune
I think you have a long story to share and i am glad after long time finally you cam and shared your experience.
Data Science course in Chennai | Best Data Science course in Chennai
Data science course in bangalore | Best Data Science course in Bangalore
Data science course in pune | Data Science Course institute in Pune
Data science online course | Online Data Science certification course-Gangboard
Data Science Interview questions and answers
Data Science Tutorial
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
aws training in bangalore
RPA Training in bangalore
Python Training in bangalore
Selenium Training in bangalore
Hadoop Training in bangalore
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
Advanced AWS Training in Bangalore | Best Amazon Web Services Training Institute in Bangalore
Advanced AWS Training Institute in Pune | Best Amazon Web Services Training Institute in Pune
Advanced AWS Online Training Institute in india | Best Online AWS Certification Course in india
AWS training in bangalore | Best aws training in bangalore
Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
microsoft azure training in bangalore
rpa training in bangalore
best rpa training in bangalore
rpa online training
This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me..
Best Devops online Training
Online DevOps Certification Course - Gangboard
Casino is not just a game but a lifestyle, come in, play and be stylish. roulette online The best casino is only on BGAOC and nowhere else.
Attend The Python training in bangalore From ExcelR. Practical Python training in bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python training in bangalore.
python training in bangalore
The article is so informative. This is more helpful for our
Best online software testing training course institute in chennai with placement
Best selenium testing online course training in chennai
Learn best software testing online certification course class in chennai with placement
Thanks for sharing.
Excellent Blog. Thank you so much for sharing.
best react js training in chennai
react js training in Chennai
react js workshop in Chennai
react js courses in Chennai
react js training institute in Chennai
reactjs training Chennai
react js online training
react js online training india
react js course content
react js training courses
react js course syllabus
react js training
react js certification in chennai
best react js training
Nice informative content Data Science Course In Chennai
Protractor Training in Chennai
jmeter training in chennai
Rpa Training in Chennai
Rpa Course in Chennai
Blue prism training in Chennai
Selenium Training In Chennai
Selenium Training In Chennai
Nice Post
For Data Science training in Bangalore, Visit:
Data Science training in Bangalore
For Blockchain training in Bangalore, Visit:
Blockchain training in Bangalore
Thanks for sharing valuable information.
Digital Marketing training Course in chennai
digital marketing training institute in chennai
digital marketing training in Chennai
digital marketing course in Chennai
digital marketing course training in omr
digital marketing certification in omr
digital marketing course training in velachery
digital marketing training center in chennai
digital marketing courses with placement in chennai
digital marketing certification in chennai
digital marketing institute in Chennai
digital marketing certification course in Chennai
digital marketing course training in Chennai
Digital Marketing course in Chennai with placement
digital marketing courses in chennai
I am really happy with your blog because your article is very unique and powerful for new reader.
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
I am really happy with your blog because your article is very unique and powerful for new reader.
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...
Looking for Hadoop Admin Training in Bangalore, learn from Softgen Infotech provide Hadoop Admin Training on online training and classroom training. Join today!
Really it was an awesome article… very interesting to read…Thanks for sharing.........
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Really it was an awesome article… very interesting to read…Thanks for sharing.........
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Really it was an awesome article… very interesting to read…Thanks for sharing.........
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
Really it was an awesome article… very interesting to read…Thanks for sharing.........
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore
python Training in Bangalore
aws Training in Bangalore
After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.
machine learning course
artificial intelligence course in mumbai
Attend The Data Science Courses From ExcelR. Practical Data Science Courses Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Science Courses.
ExcelR Data Science Courses
Data Science Interview Questions
ExcelR Business Analytics Course
wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated.
machine learning course
artificial intelligence course in mumbai
Thanks for sharing this valuable information to our vision. You have posted a worthy blog keep sharing.
Digital Marketing Course In Kolkata
Web Design Course In Kolkata
SEO Course In Kolkata
This Was An Amazing ! I Haven't Seen This Type of Blog Ever ! Thanks For Sharing,
Angular JS Training in Chennai | Certification | Online Training Course | Angular JS Training in Bangalore | Certification | Online Training Course | Angular JS Training in Hyderabad | Certification | Online Training Course | Angular JS Training in Coimbatore | Certification | Online Training Course | Angular JS Training | Certification | Angular JS Online Training Course
Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
artificial intelligence course in bangalore
This post is great. I reallly admire your post. Your post was awesome.
data science course in Hyderabad
Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
java training in chennai
java training in omr
aws training in chennai
aws training in omr
python training in chennai
python training in omr
selenium training in chennai
selenium training in omr
excellent post...thank you for the informative blog that will help me to do somthing in my life..
web designing training in chennai
web designing training in omr
digital marketing training in chennai
digital marketing training in omr
rpa training in chennai
rpa training in omr
tally training in chennai
tally training in omr
Thanks for sharing great information. I like your blog and highly recommendData Science Training in Hyderabad
Nice article, Which you have shared here about the Data Visualization. Your article is very informative and useful to know more about the benefits of Data.
oracle training in chennai
oracle training in tambaram
oracle dba training in chennai
oracle dba training in tambaram
ccna training in chennai
ccna training in tambaram
seo training in chennai
seo training in tambaram
Great Post, Thanks for sharing such a informative information.
Java Online Training
Java Online Training In Chennai
Core Java Online Training
I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
sap training in chennai
sap training in velachery
azure training in chennai
azure training in velachery
cyber security course in chennai
cyber security course in velachery
ethical hacking course in chennai
ethical hacking course in velachery
It is amazing and wonderful to visit your site.Thanks for sharing this information.
hardware and networking training in chennai
hardware and networking training in annanagar
xamarin training in chennai
xamarin training in annanagar
ios training in chennai
ios training in annanagar
iot training in chennai
iot training in annanagar
Very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing, data science course in Hyderabad
This Was An Amazing ! I Haven't Seen This Type of Blog Ever ! Thankyou For Sharing, data scientist course in hyderabad with placement
Thanks for provide great informatic and looking beautiful blog
python training in bangalore | python online Training
artificial intelligence training in bangalore | artificial intelligence online training
machine learning training in bangalore | machine learning online training
uipath-training-in-bangalore | uipath online training
blockchain training in bangalore | blockchain online training
aws training in Bangalore | aws online training
data science training in bangalore | data science online training
Actually I read it yesterday but I had some thoughts about it and today I wanted to read it again because it is very well written.
artificial intelligence course in bangalore
There is no dearth of Data Science course syllabus or resources. Learn the advanced data science course concepts and get your skills upgraded from the pioneers in Data Science.
data science course bangalore
data science course syllabus
data science training in marathahalli
I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more.
data science course in Hyderabad
Great information. The above content is very interesting to read. This will be loved by all age groups.
list to string python
data structures in python
polymorphism in python
python numpy tutorial
python interview questions and answers
convert list to string python
Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing.
data science courses
Great survey. I'm sure you're getting a great response. ExcelR Business Analytics Courses
Awesome article, I really enjoyed reading your blog. This is truly a great read for me.
methods of string class in java
string functions in java with examples
string programs in java
how to change date format in java
aws uses
software testing interview questions and answers for experienced
php developer interview questions
Post a Comment