admin管理员组文章数量:1390513
I am making requests to the Instagram API to get posts on a users feed.
There appear to be 3 types ing through; IMAGE
, VIDEO
and CAROUSEL_ALBUM
.
In the IMAGE
type, the media_url
key in the object is a link to the image.
In the VIDEO
type, the media_url
key in the object is a link to the mp4 video and it has an additional key called thumbnail_url
for the static image of the video.
The CAROUSEL_ALBUM
however only has a media_url
key (like IMAGE
) and it is only an image, even if I know that carousel contains mp4 videos.
How can I get the video on the CAROUSEL_ALBUM
type that's returned from Instagram?
I request the following fields:
`.3/${item.id}?access_token=${accessToken}&fields=id,media_type,media_url,thumbnail_url,permalink,caption,timestamp`
These requests are made in a loop from an array of post ID's. Are there additional settings I need to make?
A typical CAROUSEL_ALBUM
request I get looks like:
{
"media_type": "CAROUSEL_ALBUM",
"media_url": ".2885-15/66441408_2082905628680299_8050667243209299756_n.jpg?_nc_cat=100&_nc_oc=AQk2PElxoGzOzQ_4f-4vANh_Db1Mmra2wkci2aEKbc3vCstLzQeWQxKadbe1ByF8Vec&_nc_ht=scontent.xx&oh=5aa8ac107e1bd5da07b6cb5d760200f6&oe=5DC18C62",
"permalink": "/",
"caption": "Each video in this carousel stands for a stage in the animation process for our latest experiment, where we animated a 3d model and used it as a basis for the 2d rotoscoping.",
"timestamp": "2019-07-05T14:50:53+0000",
"id": "18053365636184706"
}
Thanks
I am making requests to the Instagram API to get posts on a users feed.
https://developers.facebook./docs/instagram-api/reference/media/#returnable-fields
There appear to be 3 types ing through; IMAGE
, VIDEO
and CAROUSEL_ALBUM
.
In the IMAGE
type, the media_url
key in the object is a link to the image.
In the VIDEO
type, the media_url
key in the object is a link to the mp4 video and it has an additional key called thumbnail_url
for the static image of the video.
The CAROUSEL_ALBUM
however only has a media_url
key (like IMAGE
) and it is only an image, even if I know that carousel contains mp4 videos.
How can I get the video on the CAROUSEL_ALBUM
type that's returned from Instagram?
I request the following fields:
`https://graph.facebook./v3.3/${item.id}?access_token=${accessToken}&fields=id,media_type,media_url,thumbnail_url,permalink,caption,timestamp`
These requests are made in a loop from an array of post ID's. Are there additional settings I need to make?
A typical CAROUSEL_ALBUM
request I get looks like:
{
"media_type": "CAROUSEL_ALBUM",
"media_url": "https://scontent.xx.fbcdn/v/t51.2885-15/66441408_2082905628680299_8050667243209299756_n.jpg?_nc_cat=100&_nc_oc=AQk2PElxoGzOzQ_4f-4vANh_Db1Mmra2wkci2aEKbc3vCstLzQeWQxKadbe1ByF8Vec&_nc_ht=scontent.xx&oh=5aa8ac107e1bd5da07b6cb5d760200f6&oe=5DC18C62",
"permalink": "https://www.instagram./p/Bzif-HhAiBk/",
"caption": "Each video in this carousel stands for a stage in the animation process for our latest experiment, where we animated a 3d model and used it as a basis for the 2d rotoscoping.",
"timestamp": "2019-07-05T14:50:53+0000",
"id": "18053365636184706"
}
Thanks
Share Improve this question edited Jul 10, 2019 at 21:33 Michael Giovanni Pumo asked Jul 10, 2019 at 21:21 Michael Giovanni PumoMichael Giovanni Pumo 14.8k18 gold badges100 silver badges145 bronze badges 2- Try add the video_url field too. Check this link: developers.facebook./docs/marketing-api/reference/… – DrFreeze Commented Jul 10, 2019 at 22:10
- @DrFreeze That does not make a difference I'm afraid. – Michael Giovanni Pumo Commented Jul 11, 2019 at 10:31
1 Answer
Reset to default 9Whilst it doesn't seem like this API returns a video at the top-level for a carousel type, I did find a work-around for anyone that may need it.
In a carousel type, there should be a key for children. So you need to request that in the field's parameters.
Using sub-fields in this children field, you can get the actual media items (videos).
For example:
const fields = [
'caption',
'children{media_type,media_url,thumbnail_url}',
'id',
'media_type',
'media_url',
'permalink',
'thumbnail_url',
'timestamp'
].join(',')
const request = await fetch(`https://graph.facebook./v3.3/${userId}/media?fields=${fields}&access_token=${accessToken}`)
In the children's key of the JSON response, you will see your videos. Simply use this to display as your main media if you so wish.
Try the Graph API Explorer to see what fields are available to you. I cannot work out how to return width and height though if anyone is aware how to do that.
https://developers.facebook./tools/explorer
本文标签: javascriptHow to return video from an Instagram media carousel albumStack Overflow
版权声明:本文标题:javascript - How to return video from an Instagram media carousel album? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744599090a2614959.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论