Reddit now offers the possibility to embed reddit posts and comments on your page. For posts, the way to do it manually is to click the "share" button, then select "embed" in the pop-up window. This creates a snippet that you can include in your page. However I would like to this automatically with posts I get and select from the reddit API.
Is there an API to generate the snippet? Should I just figure out the format and generate it myself?
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.
If you look at the code for embedding, it's pretty easy to craft yourself.
<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>
You basically need the current timestamp, the url, the title, and the subreddit. All the data is easily retrievable from the existing API. The second link I posted above should have all the information you need to craft that embed code.