如何获取 Pinterest V3 API-KEY 或 access_token [英] How to obtain Pinterest V3 API-KEY or access_token

查看:23
本文介绍了如何获取 Pinterest V3 API-KEY 或 access_token的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 Pinterest 数据,这些数据将是用户的公开信息(关注者数量等),以及用户的所有 Pin 图.

我知道 v3 API 现已上线,v2 api 已下架.

我找到了这个链接,它为我提供了我想要的终点:

http://techslides.com/most-repinned-pinterest-逐个网站/

但我无法获得 access_token.我已经向 pinterest 询问了 api 访问权限,但他们没有回复.而且我也无法嗅探应用数据.

我还尝试了 Pinterest 的签名测试工具,该工具位于其网站上,但没有成功.它生成的链接也不起作用.它返回授权失败.

https://developers.pinterest.com/tools/signature/>

我可以访问 APP-ID 和 Client-Secret.我需要知道如何获得访问令牌/API-KEY 才能使我的以下工作正常进行:

https://api.pinterest.com/v3/users/jessicamalba/?access_token=APIKEY

编辑

在我被告知这是重复的

如何获取访问令牌进行访问Pinterest API

我只想说它不是.这个问题是一年前提出的,是针对 V2 api 提出的.现在返回 404 状态.所以现在我在这里询问 V3 api.

解决方案

作为序言,我看到一些讨论,即使您可以获得令牌,除非您是经过批准的开发人员,否则它可能无法工作.因此,您可以在等待尝试解决所有这些问题的同时考虑申请成为 API 开发人员.此外,V3 是测试版,所以.. 这个答案现在可能有用,但是,如果它最终不是在测试版出来时获得令牌的官方方式,它可能在以后不起作用.

第一步:登录 pinterest,然后您需要在 https 上创建一个应用程序://developers.pinterest.com/manage/ 链接,您也可以从 pinterest 上的主要开发人员页面获取.我选择创建 IOS 应用程序,尽管我不打算在 IOS 中使用它,但我可以创建一个应用程序来尝试使 API 工作.

应用程序创建的一部分,要求您指定一个回调 url,这是您网站上将要接收令牌的 url &散列标签中的令牌相关数据{我认为他们这样做是为了只有 javascript 可以获取它而不是直接使用 php} 但是您可以修改 javascript 中的主题标签以删除散列并将其重定向到另一个可以将其收集为 get或发布参数.

创建后,将应用程序 ID1412345"(即 consumer_id,有时也称为 client_id)替换为下面的 url.

我看到的是这个数字以14开头......目前

https://www.pinterest.com/oauth/?consumer_id=1412345&response_type=token

第二步:上面执行的 url 会将您带到一个页面,要求您授权应用程序访问您的用户帐户.一旦您授权它,它就会将令牌发送回您的网站.在哈希标签中,您可以使用 javascript 读取哈希标签

window.location.hash.substr(1, window.location.hash.length) 将从包含 access_token、expires_at(以秒为单位的持续时间,等于 30 天)和 token_type 的哈希标签中获取 get params 字符串,它将等于承载者"

请注意,令牌将采用 base_64 编码,我不知道它是否应该保持这种使用方式,但我认为是这样.

I am trying to fetch Pinterest data, which would be the public info of the user(follower count etc), and all pins for a user.

I know the v3 API are up now and v2 apis have been taken down.

I found this link which gives me end points for exactly what I want:

http://techslides.com/most-repinned-pinterest-pins-by-website/

But I am unable to get an access_token. I have asked pinterest for api access but they have not replied. And I am unable to sniff app data too.

I also tried Pinterest's signature tester tool which is on their website but no luck. The link it generates doesn't work either. It returns a authorization failure.

https://developers.pinterest.com/tools/signature/

I have access to APP-ID and Client-Secret. I need to know how can I get an access token/ API-KEY to get the following work fine for me:

https://api.pinterest.com/v3/users/jessicamalba/?access_token=APIKEY

EDIT

Before I am told that is an duplicate of

How to get access token for access Pinterest Api

I would just say that it is not. This question was asked one year ago and was asked in respect to V2 api. Which now return a 404 status. So now here I am asking about the V3 api.

解决方案

To preface, I saw some discussion that even though you can get the token, it may not work unless you are an approved developer. So you might consider applying to be an API developer while you wait to try to work all this out. Also V3 is beta, so.. This answer might work for now however, it may not work later if it ends up not being the official way to get the token when it comes out of beta.

Step one: Log into pinterest then you need to create an application on the https://developers.pinterest.com/manage/ link which you can also get from the main developers page on pinterest. I chose to create IOS application, even though I don't plan to use this with IOS, just so I could get an application created to try to make the API work.

Part of the creation of the app, asks you to specify a callback url, this is the url on your website that is going to receive the token & token related data in a hash tag {I presume they did this so that only javascript can get at it rather than php directly} however you could modify the hashtag in javascript to drop the hash and redirect it to another url which can collect it as get or post params.

Once created replace the application id "1412345" (i.e. consumer_id, also sometimes called client_id) into the url below.

What I have seen is this number starts with 14...... at present

https://www.pinterest.com/oauth/?consumer_id=1412345&response_type=token

Step two: The executed url above will bring you to a page asking you to authorize the application to access your user account. Once you authorize it it will send the token back to your website. in the hash tag and you can use javascript to read the hashtag

window.location.hash.substr(1, window.location.hash.length) will get you the get params string from the hash tag containing access_token, expires_at (duration in seconds which equals 30 days) and token_type which will equal "bearer"

Note the token will be base_64 encoded, I don't know if it's supposed to stay that way to be used but I presume so.

这篇关于如何获取 Pinterest V3 API-KEY 或 access_token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆