Skip to content
Browse files

Added build_keyval & request(post, Url, Login, Pass, Args) need to test

  • Loading branch information...
1 parent 26606e0 commit 6f5626c49c2facc51bb39052031c184a18af72c8 @baphled committed
Showing with 11,609 additions and 0 deletions.
  1. +11,585 −0 erl_crash.dump
  2. +3 −0 includes/twitterl.hrl
  3. +3 −0 includes/twitterl.hrl~
  4. +3 −0 twitterl.hrl
  5. +15 −0 twitterl_interface.erl
View
11,585 erl_crash.dump
11,585 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
3 includes/twitterl.hrl
@@ -0,0 +1,3 @@
+-record(user, {id, name, screen_name, location, description, profile_image_url, url, protected, followers_count, friends_count, created_at, favourites_count, utc_offset, time_zone, following, notifications, statuses_count, status}).
+
+-record(status, {created_at, id, text, source, truncated, in_reply_to_status_id, in_reply_to_user_id, favorited,user}).
View
3 includes/twitterl.hrl~
@@ -0,0 +1,3 @@
+-record(user, {id, name, screen_name, location, description, profile_image_url, url, protected, followers_count, friends_count, created_at, favourites_count, utc_offset, time_zone, following, notifications, statuses_count,status}).
+
+-record(status, {created_at, id, text, source, truncated, in_reply_to_status_id, in_reply_to_user_id, favorited,user}).
View
3 twitterl.hrl
@@ -0,0 +1,3 @@
+-record(user, {id, name, screen_name, location, description, profile_image_url, url, protected, followers_count, friends_count, created_at, favourites_count, utc_offset, time_zone, following, notifications, statuses_count,status}).
+
+-record(status, {created_at, id, text, source, truncated, in_reply_to_status_id, in_reply_to_user_id, favorited,user}).
View
15 twitterl_interface.erl
@@ -323,6 +323,21 @@ request_url(get,Url,nil,nil) ->
%% Make an authenticated request to the specified URL.
request_url(get,Url, Login, Pass) ->
check_response(http:request(get, {Url, headers(Login, Pass)}, [], [])).
+request_url(post, Url, Login, Pass,Args) ->
+ Body = twitterl_interface:build_keyval(Args),
+ HttpResult = http:request(post, {Url, headers(Login, Pass),
+ "application/x-www-form-urlencoded", Body} , [], []),
+ check_response(HttpResponse).
+
+build_keyval(Args) ->
+ Body = lists:concat(
+ lists:foldl(
+ fun (Rec, []) -> [Rec]; (Rec, Ac) -> [Rec, "&" | Ac] end,
+ [],
+ [K ++ "=" ++ ibrowse:url_encode(V) || {K, V} <- Args]
+ )
+ ),
+ Body.
%% Checks out HTTP response, if we get a 200 retrieve
%% the response body, otherwise return the status code & message.

0 comments on commit 6f5626c

Please sign in to comment.
Something went wrong with that request. Please try again.