|
@@ -1,6 +1,6 @@
|
|
|
-module(oauth).
|
|
|
|
|
|
--export([get/3, get/5, get/6, post/3, post/5, post/6, uri/2, header/1,
|
|
|
+-export([get/3, get/5, get/6, post/3, post/5, post/6, put/6, put/7, uri/2, header/1,
|
|
|
sign/6, params_decode/1, token/1, token_secret/1, verify/6]).
|
|
|
|
|
|
-export([plaintext_signature/2, hmac_sha1_signature/5,
|
|
@@ -35,6 +35,13 @@ post(URL, ExtraParams, Consumer, Token, TokenSecret, HttpcOptions) ->
|
|
|
SignedParams = sign("POST", URL, ExtraParams, Consumer, Token, TokenSecret),
|
|
|
http_post(URL, uri_params_encode(SignedParams), HttpcOptions).
|
|
|
|
|
|
+put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret) ->
|
|
|
+ put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret, []).
|
|
|
+
|
|
|
+put(URL, ExtraParams, {ContentType, Body}, Consumer, Token, TokenSecret, HttpcOptions) ->
|
|
|
+ SignedParams = sign("PUT", URL, ExtraParams, Consumer, Token, TokenSecret),
|
|
|
+ http_put(uri(URL, SignedParams), [], {ContentType, Body}, HttpcOptions).
|
|
|
+
|
|
|
uri(Base, []) ->
|
|
|
Base;
|
|
|
uri(Base, Params) ->
|
|
@@ -179,6 +186,9 @@ http_get(URL, Options) ->
|
|
|
http_post(URL, Data, Options) ->
|
|
|
http_request(post, {URL, [], "application/x-www-form-urlencoded", Data}, Options).
|
|
|
|
|
|
+http_put(URL, Headers, {ContentType, Body}, Options) ->
|
|
|
+ http_request(put, {URL, Headers, ContentType, Body}, Options).
|
|
|
+
|
|
|
http_request(Method, Request, Options) ->
|
|
|
httpc:request(Method, Request, [{autoredirect, false}], Options).
|
|
|
|