是否可以以编程方式在页面中嵌入 Reddit 帖子?

Is it possible to programmatically embed Reddit posts in a page?

Reddit 现在可以在您的页面上 embed reddit posts and comments。对于帖子,手动操作的方法是点击"share"按钮,然后在弹出的window中点击select"embed"。这会创建一个片段,您可以将其包含在您的页面中。但是,我希望自动使用我收到的帖子和来自 reddit API.

的 select

是否有 API 生成代码段?我应该只弄清楚格式并自己生成吗?

If you check out what the API returns for a subreddit, you'll see that there isn't any data for sharing or embedding unfortunately. Same goes for a single post.

如果您查看嵌入代码,您自己制作起来非常容易。

<blockquote class="reddit-card" data-card-created="1490648549"><a href="https://www.reddit.com/r/worldnews/comments/61svww/jared_kushner_had_undisclosed_meeting_with_sergey/?ref=share&ref_source=embed">Jared Kushner had undisclosed meeting with Sergey Gorkov, the head of Russia’s state-owned Vnesheconombank, which has been under sanctions since the annexation of Crimea in 2014</a> from <a href="http://www.reddit.com/r/worldnews">worldnews</a></blockquote>
<script async src="//embed.redditmedia.com/widgets/platform.js" charset="UTF-8"></script>

您基本上需要当前时间戳、url、标题和 subreddit。所有数据都可以从现有 API 中轻松检索。我上面发布的第二个 link 应该包含制作该嵌入代码所需的所有信息。

嗯。您甚至可以使用 IFTTT.COM。删除数据卡创建部分并将 url 替换为 {{PostURL}} 和标题作品 {{title}}。希望对你有帮助。