clojure oauth和凭证 [英] clojure oauth and credentials

查看:124
本文介绍了clojure oauth和凭证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助 clojure和oauth



我在最后一步遇到困难:用凭据签署请求。

  / credentials consumer 
(:oauth_token access-token-response)
(:oauth_token_secret access-token-response)
:POST
http://twitter.com/statuses/ update.json
{:statuspost-from #clojure with #oauth}))

(http / puthttp://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 ...我使用flickr api并想要获取用户的照片。



我的问题是:我如何更改它适合的凭据flickr url?
我也困惑了:status 但是当我删除它我得到一个错误...

 (def凭据(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查询参数具有以下映射:

 (def query- params {:methodflickr.people.getPhotos:formatjson:user_id93029506 @ N07:nojsoncallback 1})

现在我们要做的是

 (http / gethttp://api.flickr .com / services / rest /{:query-params(merge credentials query-params)})


I need some help with clojure and oauth.

I got stuck at the last step: signing the request with the credentials.

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

Thats the example from github.

Now, from the flickr API I have this test-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

I dont use twitter... I use the flickr api and want to GET the pictures of a user.

My question is now: How do I have to change the credentials that it fits the flickr url? I am also confused about the :status but when I delete it I get an error...

解决方案

The Twitter example uses the HTTP POST method, but for Flickr we want GET and the flickr api. So we do

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

In the twitter example, what I replaced with query-params specifies what get posted. It is a map that will be url-encoded into something like status=posting%20from%20%23clojure%20with%20%23oauth. Conversely, the request from the API you mention has the following map for the non-oauth query-params:

(def query-params {:method "flickr.people.getPhotos" :format "json" :user_id "93029506@N07" :nojsoncallback 1})

Now all we have to do is

(http/get "http://api.flickr.com/services/rest/" {:query-params (merge credentials query-params)}) 

这篇关于clojure oauth和凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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