例如转发和点赞吗

例如转发和点赞吗

本文介绍了我可以通过他们的 API 模仿 Tumblr 交互,例如转发和点赞吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在做一个应包含 Tumblr 的单页网站.我认为有两种方法可以实现这一目标.

  1. 内嵌框架
  2. Tumblr API

由于 Iframe 感觉很糟糕,所以我想我会使用 Tumblr API.使用 API 密钥,我可以从 Tumblr 获取内容并将其放在网站上,并模仿 Tumblr 博客的外观.

现在我已经到了想要包含关注、转发和喜欢等功能的地步.这些都可以使用 API 和 Oauth 作为身份验证方法,但是,我现在想知道的是,因为我想完全模仿 Tumblr 博客的外观和感觉,我真的不希望在与我在我的单页网站上的Tumblr"(当通过 Twitter 使用 Oauth 内容时,您会看到这个弹出窗口,要求您在发生任何事情之前获得我的许可).

会这样吗?如果是这样,我是否只能通过 Iframe 在我的网站中包含 Tumblr 提要?

解决方案

为了使用 API 的关注、转发和点赞功能,您需要一个经过身份验证的用户,这需要最终用户授予访问"权限您的 API 应用程序.

换句话说,是的,会出现这样的弹出窗口",要求用户授予您的站点读取和写入"其 Tumblr 帐户的权限.

作为变通方法,它们没有完全集成,但通常可以正常工作:

要添加关注链接,请添加指向以下内容的链接:

http://www.tumblr.com/follow/{博客名称}

要包含转发链接,请包含类似以下内容的链接:

http://www.tumblr.com/reblog/{Post ID}/{Reblog Key}

reblog key"可以在API获取的post数据中获取.

至于赞"按钮——如果没有经过身份验证的用户(即,通过弹出窗口"并获取私有/公共 OAuth 密钥以访问用户的 tumblr 帐户),您将永远无法使用它/p>

但是,请记住,在您的 Tumblr 主题代码中,您可以使用 {LikeButton}.这将呈现由 Tumblr 提供的实现Like"功能的 元素.可以使用 AJAX 从您的 Tumblr 加载页面并解析出这些 元素并将它们动态插入到需要的位置.

So, I'm doing a one page site where a Tumblr should be included. I figured there were two ways to go to achieve this.

  1. Iframe
  2. Tumblr API

Since Iframe feels like bad practice I figured I'd make use of the Tumblr API. With an API key I can fetch content from the Tumblr and put it on the site and mimic the look and feel of a Tumblr blog.

Now I've reached the point where I want to include functionality such as Follow, Reblog and Like. These are all possible using the API and Oauth as auth method, BUT, what I'm wondering now, as I want to mimic the look and feel of a Tumblr blog entirely, I really don't want a popup to appear when interacting with the "Tumblr" I've got on my one page site (when using Oauth stuff via Twitter you got this popup that asks you to allow my permission before anything happens).

Will this be the case? If so, is my only resort to an Iframe to include a Tumblr feed in my site?

解决方案

In order to use the Follow, Reblog, and Like features of the API you will need an authenticated user, which requires the end user to grant "access" to your API application.

In other words, yes, such a "pop up" will appear asking the user to give your site permission to "read and write" to their Tumblr account.

As workarounds, that are not quite fully integrated but will usually work OK:

To add a Follow link, include a link to something like:

http://www.tumblr.com/follow/{Blog Name}

To include a Reblog link, include a link something like:

http://www.tumblr.com/reblog/{Post ID}/{Reblog Key}

The "reblog key" can be obtained in the post data obtained from the API.

As for the Like button -- you're just never going to get that to work without an authenticated user (ie, going through the "pop up" and obtaining private/public OAuth keys to access the user's tumblr account)

Edit:

However, remember that inside your Tumblr theme code you can use {LikeButton}. This will render an <iframe> element provided by Tumblr that implements the "Like" feature. It would be possible to load pages from your Tumblr with AJAX and parse out these <iframe> elements and insert them where needed dynamically.

这篇关于我可以通过他们的 API 模仿 Tumblr 交互,例如转发和点赞吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 07:37