Java 如何获取 Pinterest V3 API-KEY 或 access_token
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24194892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to obtain Pinterest V3 API-KEY or access_token
提问by Sambhav Sharma
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.
我正在尝试获取 Pinterest 数据,这将是用户的公共信息(关注者计数等),以及用户的所有 pin。
I know the v3 API are up now and v2 apis have been taken down.
我知道 v3 API 现在已经上线,v2 api 已经下架了。
I found this link which gives me end points for exactly what I want:
我找到了这个链接,它为我提供了我想要的终点:
http://techslides.com/most-repinned-pinterest-pins-by-website/
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.
但我无法获得 access_token。我已经向 pinterest 询问了 api 访问权限,但他们没有回复。而且我也无法嗅探应用程序数据。
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.
我还尝试了他们网站上的 Pinterest 签名测试工具,但没有成功。它生成的链接也不起作用。它返回授权失败。
https://developers.pinterest.com/tools/signature/
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:
我可以访问 APP-ID 和 Client-Secret。我需要知道如何获得访问令牌/ API-KEY 以使以下工作对我来说很好:
https://api.pinterest.com/v3/users/jessicamalba/?access_token=APIKEY
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.
我只想说它不是。这个问题是一年前提出的,是针对 V2 api 提出的。现在返回一个404
状态。所以现在我在这里询问 V3 api。
采纳答案by Damon Hogan
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.
作为序言,我看到一些讨论,即使您可以获得令牌,除非您是经过批准的开发人员,否则它可能无法工作。因此,您可以在等待尝试解决所有这些问题的同时考虑申请成为 API 开发人员。V3 也是测试版,所以.. 这个答案现在可能有用,但是,如果它最终不是在测试版出来时获得令牌的官方方式,它可能在以后不起作用。
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.
第一步:登录 pinterest,然后您需要在https://developers.pinterest.com/manage/链接上创建一个应用程序,您也可以从 pinterest 上的主要开发人员页面获取该链接。我选择创建 IOS 应用程序,即使我不打算在 IOS 中使用它,只是为了我可以创建一个应用程序来尝试使 API 工作。
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.
应用程序创建的一部分,要求您指定一个回调 url,这是您网站上的 url,它将在哈希标签中接收令牌和令牌相关数据{我认为他们这样做是为了只有 javascript 可以获取在它而不是 php 直接} 但是您可以修改 javascript 中的主题标签以删除哈希并将其重定向到另一个可以将其收集为获取或发布参数的网址。
Once created replace the application id "1412345" (i.e. consumer_id, also sometimes called client_id) into the url below.
创建后,将应用程序 ID“1412345”(即 consumer_id,有时也称为 client_id)替换为下面的 url。
What I have seen is this number starts with 14...... at present
我看到的是这个数字现在是14开头的……
https://www.pinterest.com/oauth/?consumer_id=1412345&response_type=token
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
第二步:上面执行的 url 会将您带到一个页面,要求您授权应用程序访问您的用户帐户。一旦您授权它,它就会将令牌发送回您的网站。在哈希标签中,您可以使用 javascript 读取哈希标签
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"
window.location.hash.substr(1, window.location.hash.length) 将从包含 access_token、expires_at(以秒为单位的持续时间,等于 30 天)和 token_type 的哈希标签中获取 get params 字符串,它等于“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.
请注意,令牌将采用 base_64 编码,我不知道它是否应该保持这种使用方式,但我认为是这样。
回答by Sambhav Sharma
Okay, so as of today, following are the parts of the api that are public and used by widgets.
好的,到今天为止,以下是公开并由小部件使用的 api 部分。
Public parts of API (used by widgets) Retrieving the pins on a particular board:
API 的公共部分(由小部件使用)检索特定板上的引脚:
GET http://widgets.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
GET http://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
获取http://widgets.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
获取http://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
Retrieving the pins of a particular user:
检索特定用户的引脚:
GET http://widgets.pinterest.com/v3/pidgets/users/eecolor/pins/
获取http://widgets.pinterest.com/v3/pidgets/users/eecolor/pins/
Retrieving the information of (a) particular pin(s):
检索 (a) 特定引脚的信息:
GET http://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids=521150988102375972
GET http://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids=521150988102375972,10133167885969245
获取http://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids=521150988102375972
获取http://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids=52115098972619728383
Count the number of pins:
计算引脚数:
http://widgets.pinterest.com/v1/urls/count.json?url={urlEncodedLink} http://widgets.pinterest.com/v1/urls/count.json?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fssass%2F3436030086%2F
http://widgets.pinterest.com/v1/urls/count.json?url={urlEncodedLink} http://widgets.pinterest.com/v1/urls/count.json?url=http%3A%2F%2Fwww .flickr.com%2Fphotos%2Fssass%2F3436030086%2F
Note that the link is returned in the other API responses
请注意,链接在其他 API 响应中返回
You can use ?callback=myJsFunction to use JSONP
您可以使用 ?callback=myJsFunction 来使用 JSONP
GET http://widgets.pinterest.com/v3/pidgets/boards/eecolor/test/pins/?callback=myJsFunction
获取http://widgets.pinterest.com/v3/pidgets/boards/eecolor/test/pins/?callback=myJsFunction
You can use api instead of widgets and also https
您可以使用 api 代替小部件,也可以使用 https
GET http://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
GET https://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
获取http://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
获取https://api.pinterest.com/v3/pidgets/boards/eecolor/test/pins/
回答by Amitesh Kumar
this is a official Pinterest Documentation every thing you find it here, I did same for my requirement. Access token
这是 Pinterest 官方文档,你在这里找到的每一件事,我都按照我的要求做了。 访问令牌
But it for V1 api
但它适用于 V1 api
examples:
例子:
https://api.pinterest.com/v1/pins/431430839282408407/?access_token=aaa
https://api.pinterest.com/v1/boards/lorihiney/quotes/pins/?access_token=aa&limit=20&fields=id,link,counts
https://api.pinterest.com/v1/boards/mother1086/test-title/pins/?access_token=aaa&limit=2&fields=id,link,counts