Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Found a bug in handle_status, for some reason passing nil to handle_s…
…tatus,

making sure that handle_status/4 was called made the system hang.
  • Loading branch information
baphled committed Dec 10, 2008
1 parent 5a308df commit 1b1d4f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions twitterl.erl
Expand Up @@ -19,7 +19,7 @@
-export([status_show/3]).

%User based methods
-export([user_followers/3,user_friends/3,user_timeline/3,public_timeline/3]).
-export([user_show/3,user_followers/3,user_friends/3,user_timeline/3,public_timeline/3]).
%-compile(export_all).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
Expand Down Expand Up @@ -87,7 +87,7 @@ handle_call({Client, Method, Args}, _From, State) ->
catch
Err:Msg ->
io:format("~p:~p~n", [Err, Msg]),
{error, unsupported_method}
{error, {Method, Args}}
end;
_ -> {error, unknown}
end,
Expand Down Expand Up @@ -127,11 +127,13 @@ my_timeline(Login, _Password, _Args) ->
%% These methods will return more detailed information
%% including who is friends with who & retrieving conversations.
user_followers(Login, Password, _Args) ->
twitterl_interface:handle_status(followers, Login, Password,nil).
twitterl_interface:handle_user(followers, Login, Password,nil).
user_friends(Login, Password, _Args) ->
twitterl_interface:handle_status(friends, Login, Password, nil).
twitterl_interface:handle_user(friends, Login, Password, nil).
user_timeline(Login, Password, _Args) ->
twitterl_interface:handle_status(user_timeline, Login, Password, nil).
twitterl_interface:handle_user(user_timeline, Login, Password, nil).
user_show(Login, Password, Args) ->
twitterl_interface:handle_user(user_show, Login, Password, Args).
public_timeline(Login, Password, _Args) ->
twitterl_interface:handle_status(public_timeline, Login, Password, nil).
status_show(Login, Password, Args) ->
Expand Down
12 changes: 6 additions & 6 deletions twitterl_interface.erl
Expand Up @@ -32,7 +32,7 @@
-record(tweet, {title, pubDate, link}).
-record(user, {id, name, screen_name, location, description, profile_image_url, url, protected, followers_count, status}).

-export([handle_status/4]).
-export([handle_status/3,handle_status/4]).
%-export([status_followers/2,status_friends/2]) .
% Search methods
-export([auth_user/2,trends/0,tweets/2,term/1]).
Expand Down Expand Up @@ -163,8 +163,8 @@ auth_user(Login, Password) ->

%%% Handles each of our user & status requests
%@private
handle_status(Type,User,Pass,nil) ->
handle_status(Type,User,Pass,nil);
handle_status(Type,User,Pass) ->
handle_status(Type,User,Pass,nil).
handle_status(Type,User,Pass,Args) ->
case Type of
followers ->
Expand All @@ -173,7 +173,7 @@ handle_status(Type,User,Pass,Args) ->
get_user(?StatusesUrl++"friends.xml",User,Pass);
user_show ->
case is_list(Args) of
true -> get_user(?TwitUrl"/users/show/" ++ Args ++ ".xml", User,Pass);
true -> get_user("show/" ++ Args ++ ".xml", User,Pass);
_ -> {error, {Type, Args}}
end;
user_timeline ->
Expand Down Expand Up @@ -239,10 +239,10 @@ parse_items(Xml) ->
[parse_item(Item) || Item <- xmerl_xpath:string("/rss/channel/item", Xml)].

parse_users(Xml) ->
[parse_user(User) || User <- xmerl_xpath:string("/users/user|/user",Xml)].
[parse_user(User) || User <- xmerl_xpath:string("//users/user|//user",Xml)].

parse_statuses(Xml) ->
[parse_status(Status) || Status <- xmerl_xpath:string("/statuses/status|/status",Xml)].
[parse_status(Status) || Status <- xmerl_xpath:string("//statuses/status|//status",Xml)].

parse_status(Xml) when is_list(Xml) ->
xmerl_xpath:string("/status",Xml);
Expand Down

0 comments on commit 1b1d4f6

Please sign in to comment.