We are trying to pull in posts for the hashtag #smartson on YouTube using the search endpoint in the v3 data API.
However, the following two posts are not appearing in the API results:
(1) https://www.youtube.com/watch?v=F93wt8fZ-vE
(2) https://www.youtube.com/watch?v=BIWXU3IsssY
If you follow both those links and view the description section, you'll notice they both contain the hashtag #smartson as the very first word of the description. Yet they don't show up in the API results when searching that hashtag.
I can, however, retrieve those posts by looking up the channel in which they are published (using the YouTube channel endpoint). Here is the response I get back for those two posts:
{
"kind":"youtube#searchResult",
"etag":"\"m2yskBQFythfE4irbTIeOgYYfBU/OIp6j6IiBd2nWkNA4H-3Dj6xGtw\"",
"id":{
"kind":"youtube#video",
"videoId":"BIWXU3IsssY"
},
"snippet":{
"publishedAt":"2017-06-05T10:47:48.000Z",
"channelId":"UCYEsDVnEY3xiuuzDFW6g41w",
"title":"clasohlsonworkwea",
"description":"smartson #clasohlsonworkwear #testimonial Sitter jätte bra men lite för små knäskydd.",
"thumbnails":{
"default":{
"url":"https://i.ytimg.com/vi/BIWXU3IsssY/default.jpg",
"width":120,
"height":90
},
"medium":{
"url":"https://i.ytimg.com/vi/BIWXU3IsssY/mqdefault.jpg",
"width":320,
"height":180
},
"high":{
"url":"https://i.ytimg.com/vi/BIWXU3IsssY/hqdefault.jpg",
"width":480,
"height":360
}
},
"channelTitle":"Jörgen Lyckebay",
"liveBroadcastContent":"none"
}
},
{
"kind":"youtube#searchResult",
"etag":"\"m2yskBQFythfE4irbTIeOgYYfBU/CaSiQ6lYASTi7Eia0cHbF9Gwkz4\"",
"id":{
"kind":"youtube#video",
"videoId":"F93wt8fZ-vE"
},
"snippet":{
"publishedAt":"2017-06-05T08:21:06.000Z",
"channelId":"UCYEsDVnEY3xiuuzDFW6g41w",
"title":"clasohlsonworkwear",
"description":"smartson #clasohlsonworkwear #testimonial Första testet med byxorna o klev på knapparna gör om som f..",
"thumbnails":{
"default":{
"url":"https://i.ytimg.com/vi/F93wt8fZ-vE/default.jpg",
"width":120,
"height":90
},
"medium":{
"url":"https://i.ytimg.com/vi/F93wt8fZ-vE/mqdefault.jpg",
"width":320,
"height":180
},
"high":{
"url":"https://i.ytimg.com/vi/F93wt8fZ-vE/hqdefault.jpg",
"width":480,
"height":360
}
},
"channelTitle":"Jörgen Lyckebay",
"liveBroadcastContent":"none"
}
},
{
"kind":"youtube#searchResult",
"etag":"\"m2yskBQFythfE4irbTIeOgYYfBU/EYuQkgOEkur8iziKcJuAx76XkmU\"",
"id":{
"kind":"youtube#video",
"videoId":"pW_RJqX0WGM"
},
"snippet":{
"publishedAt":"2017-04-26T15:41:54.000Z",
"channelId":"UCYEsDVnEY3xiuuzDFW6g41w",
"title":"Båt motor",
"description":"Renoverad båtmotor 2.",
"thumbnails":{
"default":{
"url":"https://i.ytimg.com/vi/pW_RJqX0WGM/default.jpg",
"width":120,
"height":90
},
"medium":{
"url":"https://i.ytimg.com/vi/pW_RJqX0WGM/mqdefault.jpg",
"width":320,
"height":180
},
"high":{
"url":"https://i.ytimg.com/vi/pW_RJqX0WGM/hqdefault.jpg",
"width":480,
"height":360
}
},
"channelTitle":"Jörgen Lyckebay",
"liveBroadcastContent":"none"
}
}
In that API response, the description begins simply with the word "smartson," not the hashtag.
Any insight on why the API is not in sync with the public YouTube.com link?
Use the Videos.list. Tried it and it doesn't ignore the hashtag.
Tried it in the API explorer and here's what I got:
"description": " . . .Tap tap tap.\n\n######tapper\n#hashtag\n#dont ignore\n##doublehashtag",
The youtube api returned the complete description, no omissions.
Related
It seams that msteams object doesn't allow to render date, when card pushed through graph api in private msteams channel.
Example is like this:
POST https://graph.microsoft.com/v1.0/teams/{team_id}/channels/{channel_id}/messages
{
"body": {
"contentType": "html",
"content": "<attachment id=\"1\"/>"
},
"attachments":[
{
"contentType":"application/vnd.microsoft.card.adaptive",
"id":"1",
"content":"{\"type\":\"AdaptiveCard\",\"body\":[{\"text\":\"<at>Lev</at> hello {{ DATE(2021-04-28T00:00:00Z, SHORT) }}\",\"wrap\":true,\"type\":\"TextBlock\"}],\"version\":\"1.3\",\"msteams\":{\"entities\":[{\"type\":\"mention\",\"text\":\"<at>Lev</at>\",\"mentioned\":{\"id\":\"29:131...Rg\",\"name\":\"Lev\"}}]}}"
}
]
}
Example in teams
Is there some workaround?
msteams object is not allowed through Graph API. Only Bots have access to the msteams object. This is by design.
The at mention object when you send from bot, the user will get notify in teams activity and the card will display as shown in below image
and the at mention in adaptive card using graph api post request, the user will not get notify in teams activity and the card will display as shown in below image
Please check the below request body
{
"body": {
"contentType": "html",
"content": "<attachment id=\"1\"/>"
},
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"id": "1",
"content": "{ \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\", \"type\": \"AdaptiveCard\", \"version\": \"1.0\", \"body\": [ { \"type\": \"TextBlock\", \"text\": \"Your package will arrive on {{DATE(2017-02-14T06:00:00Z, SHORT)}} at {{TIME(2017-02-14T06:00:00Z)}}\", \"wrap\": true } ]}"
}
]
}
I'm trying to get all the eventMessages that belongs to a specific event. However I'm not being able to.
I'm querying the me/messages with the $expand=microsoft.graph.eventMessage/event and trying to filter on this relationship:
https://graph.microsoft.com/v1.0/me/messages?$expand=microsoft.graph.eventMessage/event&filter=event/id eq 'eventID'
However, I'm getting the following error
{
"error": {
"code": "RequestBroker--ParseUri",
"message": "Could not find a property named 'event' on type 'Microsoft.OutlookServices.Message'.",
"innerError": {
"request-id": "cb211061-802b-4657-a191-f06c449897d1",
"date": "2019-05-16T14:01:43"
}
}
}
But looking at their example of expanding the message with the event, there is an event property on the return of the API (see returned JSON below).
HTTP/1.1 200 OK
Content-type: application/json
{
"#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('8fd6e83b-3cc0-4bf0-8b26-950f4d7110f6')/messages/$entity",
"#odata.type":"#microsoft.graph.eventMessage",
"#odata.etag":"W/\"CwAAABYAAABXlB/SL0N4Q6g6o+jSYAEuAAAImkVF\"",
"id":"AAMkADYAAAImV_jAAA=",
"createdDateTime":"2017-12-27T21:54:55Z",
"lastModifiedDateTime":"2017-12-27T23:26:38Z",
"changeKey":"CwAAABYAAABXlB/SL0N4Q6g6o+jSYAEuAAAImkVF",
"categories":[
],
"receivedDateTime":"2017-12-27T21:54:55Z",
"sentDateTime":"2017-12-27T21:54:54Z",
"hasAttachments":false,
"internetMessageId":"<MWHPR1301MB211042CF#MWHPR1301MB2110.namprd13.prod.outlook.com>",
"subject":"Kick off planning",
"bodyPreview":"Let's collect opinions from our teams and organize action items.",
"importance":"normal",
"parentFolderId":"AQMkADYAS4AAAIBDAAAAA==",
"conversationId":"AAQkADYRuffB3wDlPn-ReFZarI60=",
"isDeliveryReceiptRequested":null,
"isReadReceiptRequested":false,
"isRead":false,
"isDraft":false,
"webLink":"https://outlook.office365.com/owa/?ItemID=AAMkADYAAAImV%2BjAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification":"focused",
"meetingMessageType":"meetingRequest",
"body":{
"contentType":"html",
"content":"<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n<style type=\"text/css\" style=\"display:none\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n</head>\r\n<body dir=\"ltr\">\r\n<div id=\"divtagdefaultwrapper\" dir=\"ltr\" style=\"font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif\">\r\n<p style=\"margin-top:0; margin-bottom:0\">Let's collect opinions from our teams and organize action items.<br>\r\n</p>\r\n</div>\r\n</body>\r\n</html>\r\n"
},
"sender":{
"emailAddress":{
"name":"Administrator",
"address":"admin#contoso.onmicrosoft.com"
}
},
"from":{
"emailAddress":{
"name":"Administrator",
"address":"admin#contoso.onmicrosoft.com"
}
},
"toRecipients":[
{
"emailAddress":{
"name":"Alex Wilber",
"address":"AlexW#contoso.onmicrosoft.com"
}
}
],
"ccRecipients":[
],
"bccRecipients":[
],
"replyTo":[
],
"event#odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('8fd6e83b-3cc0-4bf0-8b26-950f4d7110f6')/messages('AAMkADYAAAImV_jAAA%3D')/microsoft.graph.eventMessage/event/$entity",
"event":{
"#odata.etag":"W/\"V5Qf0i9DeEOoOqPo0mABLgAACJpBWg==\"",
"id":"AAMkADYAAAImVu6AAA=",
"createdDateTime":"2017-12-27T21:54:55.2624551Z",
"lastModifiedDateTime":"2017-12-27T22:19:16.6667889Z",
"changeKey":"V5Qf0i9DeEOoOqPo0mABLgAACJpBWg==",
"categories":[
],
"originalStartTimeZone":"Pacific Standard Time",
"originalEndTimeZone":"Pacific Standard Time",
"iCalUId":"040000008200E00074C5B7101A82E00800000000A2A6F3535D7FD3010000000000000000100000003D770E2E8974F44B9471BDB348097FE3",
"reminderMinutesBeforeStart":15,
"isReminderOn":true,
"hasAttachments":false,
"subject":"Kick off planning",
"bodyPreview":"Let's collect opinions from our teams and organize action items.",
"importance":"normal",
"sensitivity":"normal",
"isAllDay":false,
"isCancelled":false,
"isOrganizer":false,
"responseRequested":true,
"seriesMasterId":null,
"showAs":"tentative",
"type":"singleInstance",
"webLink":"https://outlook.office365.com/owa/?itemid=AAMkADYAAAImVu6AAA%3D&exvsurl=1&path=/calendar/item",
"onlineMeetingUrl":null,
"responseStatus":{
"response":"tentativelyAccepted",
"time":"2017-12-27T22:19:12.6197462Z"
},
"body":{
"contentType":"html",
"content":"<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n<style type=\"text/css\" style=\"display:none\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n</head>\r\n<body dir=\"ltr\">\r\n<div id=\"divtagdefaultwrapper\" dir=\"ltr\" style=\"font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif\">\r\n<p style=\"margin-top:0; margin-bottom:0\">Let's collect opinions from our teams and organize action items.<br>\r\n</p>\r\n</div>\r\n</body>\r\n</html>\r\n"
},
"start":{
"dateTime":"2018-02-02T22:00:00.0000000",
"timeZone":"UTC"
},
"end":{
"dateTime":"2018-02-02T23:00:00.0000000",
"timeZone":"UTC"
},
"location":{
"displayName":"Mt. Hood"
},
"recurrence":null,
"attendees":[
{
"type":"required",
"status":{
"response":"none",
"time":"0001-01-01T00:00:00Z"
},
"emailAddress":{
"name":"Administrator",
"address":"admin#contoso.onmicrosoft.com"
}
},
{
"type":"required",
"status":{
"response":"tentativelyAccepted",
"time":"0001-01-01T00:00:00Z"
},
"emailAddress":{
"name":"Alex Wilber",
"address":"AlexW#contoso.onmicrosoft.com"
}
}
],
"organizer":{
"emailAddress":{
"name":"Administrator",
"address":"admin#contoso.onmicrosoft.com"
}
}
}
}
I would expect that the above filter would make the API return only the messages belonging to that event. However, it's giving me a 400 and I think it might be because of the syntax on how to filter in this specific case, but I can't find anything on their documentation about this. Does anybody know how to perform this kind of filter on the graph API?
I have a Google YouTube API demo application to upload video to youtube. I got 200 response code from google but can't see the video file. Now if I go to my youtube account to see list of video uploaded, found " Upload failed: Can't process file". Please check my attached screen shot and response body:
responseBody:protected
]=>{
"kind":"youtube#video",
"etag":"\"ld9biNPKjAjgjV7EZ4EKeEGrhao/g2r-EnOHW5MpVltTX_2yOkmTkp0\"",
"id":"AwLj-Vd1xvg",
"snippet":{
"publishedAt":"2017-11-08T07:13:47.000Z",
"channelId":"UCSdakp1jDxb7-TcaxmPux1A",
"title":"Spencers Recipe123",
"description":"Test by spenvcer",
"thumbnails":{
"default":{
"url":"https://i.ytimg.com/vi/AwLj-Vd1xvg/default.jpg",
"width":120,
"height":90
},
"medium":{
"url":"https://i.ytimg.com/vi/AwLj-Vd1xvg/mqdefault.jpg",
"width":320,
"height":180
},
"high":{
"url":"https://i.ytimg.com/vi/AwLj-Vd1xvg/hqdefault.jpg",
"width":480,
"height":360
}
},
"channelTitle":"Srijabrat Dolai",
"tags":[
"tag"
],
"categoryId":"22",
"liveBroadcastContent":"none",
"localized":{
"title":"Spencers Recipe123",
"description":"Test by spenvcer"
}
},
"status":{
"uploadStatus":"uploaded",
"privacyStatus":"unlisted",
"license":"youtube",
"embeddable":true,
"publicStatsViewable":true
}
}
I have to update multiple invideo promotion details for a particular channel.
My request is as follows:
var requestOptions={
part: 'invideoPromotion',
onBehalfOfContentOwner: 'contentOwner',
resource:{
id: channelId,
invideoPromotion: {
"defaultTiming": {
"offsetMs": 2000,
"type": "offsetFromStart"
},
"items": [
{
"promotedByContentOwner": true,
"timing":
{
"offsetMs":4000,
"duration" : 5000,
"type":"offsetFromStart"
},
"id":{
"videoId": videoid1,
"type": "video"
}
},
{
"promotedByContentOwner": true,
"timing":
{
"offsetMs":11000,
"duration" : 5000,
"type":"offsetFromStart"
},
"id":{
"videoId": videoId2,
"type": "video"
}
}
],
"position": {
"type": "corner",
"cornerPosition": "topLeft"
}
}
}
};
console.log(requestOptions);
var request = gapi.client.youtube.channels.update(requestOptions);
request.execute(function (response) {});
But when i try to execute this, I am getting error
0: {error:{code:500}, id:gapiRpc}
error: {code:500}
code: 500
id: "gapiRpc"
Even When I try to do this using the youtube api explorer
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.update ,
I am getting Internal server Error.
Can somebody let me know where I am going wrong.
You cannot promote more than one video. I also tried the same but getting an error "exceeded the number of promoted items". So you can only promote one video at a time.
On a site I'm developing I embed videos from YouTube and want to get the video title and its description.
How do I get that information?
You can do it with oembed.
Example:
http://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3DM3r2XDceM6A&format=json
Youtube API V2.0 has been deprecated. It shows some wrong value for title "youtube.com/devicesupport" . pLease switch on to API V3.0
YOu can refer the following PHP code and modify yours in js or jquery as per your needs..
function youtube_title($id) {
$id = 'YOUTUBE_ID';
// returns a single line of JSON that contains the video title. Not a giant request.
$videoTitle = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=".$id."&key=YOUR_API_KEY&fields=items(id,snippet(title),statistics)&part=snippet,statistics");
// despite # suppress, it will be false if it fails
if ($videoTitle) {
$json = json_decode($videoTitle, true);
return $json['items'][0]['snippet']['title'];
} else {
return false;
}
}
update:
Jquery code to get the title-
$.getJSON('https://www.googleapis.com/youtube/v3/videos?id={VIDEOID}&key={YOUR API KEY}&part=snippet&callback=?',function(data){
if (typeof(data.items[0]) != "undefined") {
console.log('video exists ' + data.items[0].snippet.title);
} else {
console.log('video not exists');
}
});
To get the DESCRIPTION element, you need to access the gdata version of the video's info, and you can return json using alt=json on the path. In this case, oHg5SJYRHA0 is the video ID, found at the end of the url of the video you're working with on YouTube, e.g.
www.youtube.com/watch?v=oHg5SJYRHA0
http://gdata.youtube.com/feeds/api/videos/oHg5SJYRHA0?v=2&alt=json&prettyprint=true
(the prettyprint is formatting to make that easy to read, you don't need it for what you're doing)
You can grab the JSON, add it into a variable and access it using jQuery:
var youTubeURL = 'http://gdata.youtube.com/feeds/api/videos/oHg5SJYRHA0?v=2&alt=json';
var json = (function() {
var json = null;
$.ajax({
'async': false,
'global': false,
'url': youTubeURL,
'dataType': "json",
'success': function(data) {
json = data;
}
});
return json;
})();
Then access it using object notation:
alert("Title: " + json.entry.title.$t +"\nDescription:\n " + json.entry.media$group.media$description.$t + "\n");
gdata is no longer available
you can use the following instead
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=(Video_ID)&key=(API_Key)
I read this topic a bit in delay.
I did something like this using jSON and YT API's
$json = json_decode( file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$rs['vid']."?v=2&prettyprint=true&alt=jsonc") );
Note: $rs['vid'] is the video ID dinamically retrived from my DB.
Once you put the contents in the handle $json you can retrive like this:
$json->data->description;
$json->data->title;
use var_dump( $json ) to view all values you can access.
I'd start by taking a look at Youtube Data API to get what you want: http://code.google.com/apis/youtube/getting_started.html#data_api
GData is deprecated, but one can still get the video description by calling this endpoint:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id=[video_id]&key=[api_key]
It will return a response of the form:
{
"kind": "youtube#videoListResponse",
"etag": "\"...\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"...\"",
"id": "...",
"snippet": {
"publishedAt": "...",
"channelId": "...",
"title": "...",
"description": "...",
"thumbnails": { ... },
"channelTitle": "...",
"tags": [ ... ],
"categoryId": "...",
"liveBroadcastContent": "...",
"localized": {
"title": "...",
"description": "..."
},
"defaultAudioLanguage": "..."
}
}
]
}
The description can be found at items.localized.description.