我需要一些帮助 clojure and oauth .
我在最后一步卡住了:使用凭据签署请求。
(def credentials (oauth/credentials consumer
(:oauth_token access-token-response)
(:oauth_token_secret access-token-response)
:POST
"http://twitter.com/statuses/update.json"
{:status "posting from #clojure with #oauth"}))
(http/put "http://twitter.com/statuses/update.json"
:query-params credentials)
这就是github的例子。
现在,从 flickr API 我有这个测试网址:
http://api.flickr.com/services/rest/?method=flickr.people.getPhotos
&api_key=82d4d4ac421a5a22et4b49a04332c3ff
&user_id=93029506%40N07&format=json&nojsoncallback=1
&auth_token=72153452760816580-cd1e8e4ea15733c3
&api_sig=b775474e44e403a79ec2a58d771e2022
我不使用推特...我使用 flickr api 并想获取用户的图片。
我现在的问题是:我必须如何更改适合 flickr url 的凭据?
我也对
:status
感到困惑但是当我删除它时,我收到一个错误...
最佳答案
Twitter 示例使用 HTTP POST 方法,但对于 Flickr,我们需要 GET 和 flickr api。所以我们做
(def credentials (oauth/credentials consumer
(:oauth_token access-token-response)
(:oauth_token_secret access-token-response)
:GET
"http://api.flickr.com/services/rest/"
query-params))
在 Twitter 示例中,我用
query-params
替换的内容指定发布的内容。它是一个将被 url 编码成类似
status=posting%20from%20%23clojure%20with%20%23oauth
的 map .相反,来自您提到的 API 的请求具有以下非 oauth 查询参数的映射:(def query-params {:method "flickr.people.getPhotos" :format "json" :user_id "93029506@N07" :nojsoncallback 1})
现在我们要做的就是
(http/get "http://api.flickr.com/services/rest/" {:query-params (merge credentials query-params)})
关于oauth - clojure oauth 和凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14864142/