简体   繁体   English

通过 JavaScript 嵌入 Instagram

[英]Embedding Instagram via JavaScript

We are using Instagram's oEmbed-API to get embed codes.我们正在使用 Instagram 的 oEmbed-API 来获取嵌入代码。 However, we do not want to solely rely on that API and generate embed codes ourselves.但是,我们不想仅仅依赖该 API 并自己生成嵌入代码。 The embed code as provided by the API (or the website) includes a lot of html, css image data and text content, all of that already has to be there before you can work the embed js on it. API(或网站)提供的嵌入代码包括大量 html、css 图像数据和文本内容,所有这些都必须存在,然后您才能在其上工作嵌入 js。 This is a problem because we cannot implement a generic embed code but have to know the instagram content for each photo or video in advance.这是一个问题,因为我们无法实现通用的嵌入代码,但必须提前知道每张照片或视频的 Instagram 内容。

My question is: Ist there a generic embed code, something like this, for instagram?我的问题是:是否有一个通用的嵌入代码,像这样,用于 instagram?

<script async defer=\"defer\" src=\"//platform.instagram.com/en_US/embeds.js\"></script>
<script>instgrm.Embeds.genenerate('some instragram ID for instance')<script/>

You can use iframe to embed like this:您可以使用iframe像这样嵌入:

<iframe src="https://www.instagram.com/p/BFKjVxkBsCC/embed" width="400" height="480" frameborder="0" scrolling="no" allowtransparency="true"></iframe>

adding /embed to instagram post URL will give you image that can be embedded/embed添加到 Instagram 帖子 URL 将为您提供可以嵌入的图像

adding /embed/captioned will add caption to the image添加/embed/captioned将为图像添加标题

Here is link to easily generate embed code: https://www.picodash.com/instagram/embed#https://www.instagram.com/p/BFKjVxkBsCC/这是轻松生成嵌入代码的链接: https : //www.picodash.com/instagram/embed#https : //www.instagram.com/p/BFKjVxkBsCC/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM