【问题标题】:Is it possible to programmatically embed Reddit posts in a page?是否可以以编程方式在页面中嵌入 Reddit 帖子?
【发布时间】:2017-12-06 07:33:37
【问题描述】:

Reddit 现在可以在您的页面上embed reddit posts and comments。对于帖子,手动执行的方法是单击“共享”按钮,然后在弹出窗口中选择“嵌入”。这将创建一个可以包含在页面中的 sn-p。但是,我想自动使用我从 reddit API 中获取和选择的帖子。

是否有生成 sn-p 的 API?我应该弄清楚格式并自己生成吗?

【问题讨论】:

    标签: asp.net-web-api web embed reddit


    【解决方案1】:

    If you check out what the API returns for a subreddit,很遗憾,您会看到没有任何数据可供共享或嵌入。 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 轻松检索。我在上面发布的第二个链接应该包含制作嵌入代码所需的所有信息。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-04
        • 2023-02-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多