Contentful Video Content - content-management-system

How does contentful return video content? Is it returned in JSON format or is it returned as a binary data stream? Contentful's delivery api always seems to return REST response ,however I am not sure how video content is returned and served.

Video, and any other kinds of media are stored as Assets. When you get an Asset from the REST API it is returned as JSON, with a property containing a url to the relevant media file stored in that asset.
You can see that in this particular example from the API docs:
{
"fields": {
"title": "Nyan Cat",
"file": {
"fileName": "Nyan_cat_250px_frame.png",
"contentType": "image/png",
"url": "//images.contentful.com/cfexampleapi/4gp6taAwW4CmSgumq2ekUm/9da0cd1936871b8d72343e895a00d611/Nyan_cat_250px_frame.png",
"details": {
"image": {
"width": 250,
"height": 250
},
"size": 12273
}
}
},
"sys": {
...
}
}
In this case it's an image, but if it was a video you'd have a video url instead and the relevant content type.
More details here https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets/assets-collection/get-a-single-asset?console=1

Related

Add files to Salesforce CMS channel folder via Connect API?

I'm developing an integration that will programmatically create product entries in Salesforce, and part of that process needs to be the addition of product images. I'm using the Connect API and am able to make a GET call to the right folder like this (I've scrambled the IDs and what not for this example):
https://example.salesforce.com/services/data/v52.0/connect/cms/delivery/channels/0591G0000000006/contents/query?folderId=9Pu1M000000fxUMSYI
That returns a payload like this:
{
"currentPageUrl": "/services/data/v52.0/connect/cms/delivery/channels/0ap1G0000000006/contents/query?page=0&pageSize=250",
"items": [
{
"contentKey": "MCZ2YVCGLNSBETNIG5P5QMIS4KNA",
"contentNodes": {
"source": {
"fileName": "PET Round.jpg",
"isExternal": false,
"mediaType": "Image",
"mimeType": "image/jpeg",
"nodeType": "MediaSource",
"referenceId": "05T0R000005MthL",
"resourceUrl": "/services/data/v52.0/connect/cms/delivery/channels/0ap1G0000000007/media/MCY2YVCGLNSBETNIG5P4QMIS4KNA/content",
"unauthenticatedUrl": "/cms/delivery/media/MCZ2YVCGLNSBETNIG5P4QMIS4KNA",
"url": "/cms/delivery/media/MCY2YVCGLNSBETNIG5P4QMIS4KNA"
},
"title": {
"nodeType": "NameField",
"value": "844333"
}
},
"contentUrlName": "844333",
"language": "en_US",
"managedContentId": "20T0R0000008U9qUAE",
"publishedDate": "2021-08-18T16:20:57.000Z",
"title": "844333",
"type": "cms_image",
"typeLabel": "Image",
"unauthenticatedUrl": "/cms/delivery/v52.0/0DB1G0000008tfOWAU/contents/20Y0R0000008y9qUAE?oid=00D0R000000OI7GUAW"
}
]
}
I am also able to retrieve images by contentKey with a GET call like this:
https://example.salesforce.com/services/data/v52.0/connect/cms/delivery/channels/0ap1G0000000007/media/MCZ2ZVCGLNSBETMIG5P4QMIS4KNA/content
Anyone know what the endpoint should look like and what parameters etc it should have? I'm having trouble finding anything for this specific scenario in the docs but surely there's a way.
Thanks!

Facebook for developers, get url from photo param

I'm trying the API Graph explorer, I'd like the photos param to give back the photo url but I can't set it in the GET request which currently is graph.facebook.com/v2.9/me?fields=id,name,photos
"id": "22331427282551006",
"name": "USER",
"photos": {
"data": [
{
"created_time": "2017-07-01T03:36:09+0000",
"id": "85419012312312"
},
{
"created_time": "2016-06-21T04:23:13+0000",
"id": "10112312312312311"
},
{
"created_time": "2016-01-31T13:03:50+0000",
"id": "12207150957211111"
},
{
"created_time": "2014-10-06T04:30:04+0000",
"id": "12312312312312312"
Also tried graph.facebook.com/v2.9/me?fields=id,name,photos?type=uploaded as said in this reference to get uploaded photos with unexpected errors.
You want the content of the images field below the photos edge, so you need to ask for that explicitly as well.
me?fields=id,name,photos{images}
If you need more sub-fields of the photos edge, then you need to include those as well, comma-separated.
https://developers.facebook.com/docs/graph-api/using-graph-api/#fieldexpansion

How to get images field from a Group Feed - Facebook Graph API

I have been using Graph API for a while, but I am not able to figure this one out.
I have a group id, from whose feed I want to get the image urls for all available resolutions.
I know I can do that using the 'images' field of a photo id.
Here is a sample code which gets the id
<group-id>/feed?fields=attachments{target{id}}
I tried
<group-id>/feed?fields=attachments{target{id{images}}}
and also this
<group-id>/feed?fields=attachments.fields(target.fields(id{images}))
and this
<group-id>/feed?fields=attachments.fields(target.fields(id.fields(images)))
All of them return the JSON having the id, but not the images details I need.
I hope I have provided enough information.
You can use the below format while calling the API and it will return you with the images URL included in the post
<group-id>/feed?fields=created_time,attachments,message
You will get the response in the below format.
{
"created_time": "2017-11-16T06:21:37+0000",
"id": "543993212434753_1004360179731385",
"attachments": {
"data": [
{
"description": "Best #ethnic wear store for #women.
Shop Now>> sairandhri.com",
"media": {
"image": {
"height": 720,
"src": "https://scontent.xx.fbcdn.net/v/t1.0-9/s720x720/23519069_887109751445971_6170575397465061641_n.jpg?oh=170436ae447ec615f547d700017c67b4&oe=5AA4F844",
"width": 537
}
},
"target": {
"id": "887109751445971",
"url": "https://www.facebook.com/SairandhriShowroom/photos/a.302015823288703.1073741828.300462640110688/887109751445971/?type=3"
},
"type": "photo",
"url": "https://www.facebook.com/SairandhriShowroom/photos/a.302015823288703.1073741828.300462640110688/887109751445971/?type=3"
}
]
}
}
Its working and tested on Graph API Explorer

Facebook GraphAPI picture/full_picture permanent link

How can I get a permanent link for pictures in a post? For example, I can get all information about one post:
912163612218997/?fields=picture,full_picture,attachments
{
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/15390764_10154771322382505_5131571043698309499_n.jpg?oh=de4126b3944deb9fb7fca6b534e5e987&oe=58E45F29",
"full_picture": "https://scontent.xx.fbcdn.net/v/t31.0-8/s720x720/15326300_10154771322382505_5131571043698309499_o.jpg?oh=414291d1c1fbc88988afb887177a03c5&oe=59156F5D",
"id": "189675924467773_912163612218997",
"attachments": {
"data": [
{
"description": ...,
"media": {
"image": {
"height": 372,
"src": "https://scontent.xx.fbcdn.net/v/t31.0-8/s720x720/15326300_10154771322382505_5131571043698309499_o.jpg?oh=414291d1c1fbc88988afb887177a03c5&oe=59156F5D",
"width": 720
}
},
"target": {
"id": "10154771322382505",
"url": "https://www.facebook.com/photo.php?fbid=10154771322382505&set=gm.912163612218997&type=3"
},
"type": "photo",
"url": "https://www.facebook.com/photo.php?fbid=10154771322382505&set=gm.912163612218997&type=3"
}
]
}
}
However, these picture links are temporary. It won't be available after several hours.
Is there any way to get the permanent picture URL from Facebook GraphAPI?
I sort of figure out a workaround using redirect:
Fire graph API using object id and get CDN URL
Redirect to the CDN URL
Basically, as long as we know the object id, we can get the URL. Unfortunately, it is a bit slow.

Facebook graph API call for external URL not working with Youtube Urls

I was trying to get details of youtube urls using for example this video url :
/v2.5/?id=https://www.youtube.com/watch?v=AU_a76wE8fg
but whatever video url I use, its returning this template result -
{
"og_object": {
"id": "10150122667264389",
"description": "Judas Priest's official music video for 'Turbo Lover'. Click to listen to Judas Priest on Spotify: http://smarturl.it/JudasPriestSpotify?IQid=JudasPTL As fea...",
"title": "Judas Priest - Turbo Lover",
"type": "video.other",
"updated_time": "2016-01-17T18:59:08+0000",
"url": "https://www.youtube.com/watch?v=JhY9GOhFwN4"
},
"share": {
"comment_count": 28,
"share_count": 40022
},
"id": "https://www.youtube.com/watch?v"
}
What is wrong. Is facebook API broken for external urls from youtube ? Because its working fine with other website urls.
You need to UrlEncode the URL, because it contains a =. This is visible because the result contains only "id": "https://www.youtube.com/watch?v" and not "id": "https://www.youtube.com/watch?v=AU_a76wE8fg"
So /v2.5/?id=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DAU_a76wE8fg should to the trick.