oauth - clojure oauth 和凭据

标签 oauth clojure flickr

我需要一些帮助 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/

相关文章:

python - 使用 Python 访问 Lovoo API

ColdFusion/OAuth/Twitter API

csv - 如何从 compojure API 流式传输大型 CSV 响应,以便整个响应不会立即保存在内存中?

clojure - 有没有人在网络应用程序中使用过 Incanter 来提供统计图表?

flash - 安全错误: Error #2122: Security sandbox violation

iphone - ObjectiveFlickr - 如何在响应之前未知的照片 ID 上调用 getSizes?

iphone - Objective Flickr 照片上传错误

oauth - 我可以将 grant_type=client_credentials 用于 google api 吗?

javascript - 在 javascript 中使用 OAuth 连接 Github

macros - 如何向类 defn 的 Clojure 宏添加文档字符串支持?