clojure oauth and credentials



我需要一些clojure和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我有了这个测试url:

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

我不使用twitter。。。我使用flickrAPI,想要获取用户的图片。

我现在的问题是:我必须如何更改符合flickr url的凭据?我也对:status感到困惑,但当我删除它时,我得到了一个错误。。。

Twitter示例使用HTTPPOST方法,但对于Flickr,我们需要GET和flickrAPI。所以我们做

(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的映射。相反,您提到的来自API的请求对于非oauth查询-ram有以下映射:

(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)}) 

最新更新