
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
We can integrate Service-now with YouTube by using google API.
Here i tried to Retrieve one of the YouTube Video "View Count" , "Likes", "Number of Comments".
Steps:
- You need to check the API from https://console.developers.google.com.
- once you access the above URL then you need to create a Project.
if you see i have already create one project as "ServiceNow Dev". same way you can create your new project.
Once you will create the project then go to the "Credentials" and click on edit icon to copy the API Key.
Once you will be done with above steps then you will use the "YouTube.videos.list" API to get the YouTube videos count, like , or other details related to video.
if you want to learn more about the YouTube API you can refer the below link.
https://developers.google.com/apis-explorer/#s/
Now i am coming to the Service-now , here i have used rest message.
Rest Message:
Business rule i used :
(function executeRule(current, previous /*null when async*/) {
// Add your code here
try {
var r = new sn_ws.RESTMessageV2('youtubeApi', 'Default GET');
r.setStringParameterNoEscape('YOUR_API_KEY', 'AIzaSyBcvG_6AknJN30yT4y9RSOqncVOe0gW_Ns');
r.setStringParameterNoEscape('video_id',current.u_video_id);
var json = new global.JSON();
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log('check status'+httpStatus);
var decodedResponse = json.decode(responseBody);
var check = decodedResponse.items.length;
for(var i=0; i<check; i++)
{
gs.log('hey hey'+decodedResponse.items[i].statistics.viewCount);
var gr = new GlideRecord('u_youtube_applciation');
gr.get(current.sys_id);
gr.u_video_view_count=decodedResponse.items[i].statistics.viewCount;
gr.u_number_of_likes=decodedResponse.items[i].statistics.likeCount;
gr.u_video_comment_count=decodedResponse.items[i].statistics.commentCount;
gr.update();
}
}
catch(ex) {
var message = ex.message;
}
})(current, previous);
i have created one custom table with the columns "Video ID" , "Video Count", "Number of Likes" , "Video Comment Count".
so here i will simply pass the YouTube video id and based on that it will fetch the number of details.
Example : I opened any youtube video and copied the id and paste it in my "Video Id" field then it will give me the details like below.
if you see the number of likes, views comment count came in my fields.
many other integration we can do by using google API with service-now.
Thanks,
Harshvardhan
- 4,226 Views
- « Previous
-
- 1
- 2
- Next »
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.