从 API 检索 Instagram 视频嵌入 URL [英] Retrieve Instagram video embed URL from API
问题描述
我正在尝试以编程方式获取 Instagram 视频的嵌入链接.不幸的是,Instagram 的 oEmbed 端点似乎将视频视为照片,并且只返回关键帧图像,而不提供嵌入链接.
I'm trying to find to programmatically get the embed link for an Instagram video. Unfortunately, it appears that Instagram's oEmbed endpoint, treats videos as photos, and only returns the key frame image, rather than providing an embed link.
有谁知道一种无需手动访问该视频的页面即可检索 Instagram 视频的嵌入链接的方法?
Does anyone know of a way to retrieve the embed link for an instagram video without having to manually visit the page for that video?
推荐答案
According to Instagram's API site a GET /media/media-id request for a video object returns a JSON object with the information you need in "data.videos.low_resolution.url".
我使用以下代码成功地将他们的示例请求返回的视频嵌入到网页中:
I successfully embedded the video returned by their sample request into a web page with the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Video Embed Test</title>
</head>
<body>
<video width="480" height="480" controls>
<source src="http://distilleryvesper9-13.ak.instagram.com/090d06dad9cd11e2aa0912313817975d_102.mp4"
type="video/mp4"/>
</video>
</body>
</html>
这篇关于从 API 检索 Instagram 视频嵌入 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!