Skip to content

Commit

Permalink
General housekeeping and refactoring to clean up twitterl_interfaces
Browse files Browse the repository at this point in the history
dual functionality (searching and retrieve user info).
  • Loading branch information
baphled committed Dec 7, 2008
1 parent 82c7093 commit dcbd78f
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions twitterl_interface.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
%%%-------------------------------------------------------------------
%%% File : twitterl.erl
%%% Author : Yomi (baphled boodah) Akindayini <yomi@boodah.net>
%%% Description : Basic Twitter API, used to interact with twitter.
%%% Description : Basic Twitter ineterface, used by twitterl to retrieve
%%% search and status information from twitter.
%%%
%%% twitterl is free software: you can redistribute it and/or modify
%%% it under the terms of the GNU Lesser General Public License as
Expand Down Expand Up @@ -140,6 +141,18 @@ user_timeline(User) ->
public_timeline() ->
get_twitters(?PubTimeUrl).

%% Checks to see if the user can actually log in.
auth_user(Login, Password) ->
case request_url(?VerifyUrl, Login, Password) of
{ok,Body} ->
case Body of
"<authorized>true</authorized>" -> true;
_ -> false
end;
{error,Error} ->
{error,Error}
end.

%% Methods to retrieve user based information.

%% Retrieves a users followers.
Expand All @@ -153,6 +166,7 @@ status_followers(User, Pass) ->
{error,Error}
end.

%% Parsing functionality
get_xml(Url) ->
case request_url(Url,nil,nil) of
{ok, Body} ->
Expand Down Expand Up @@ -180,7 +194,6 @@ get_twitters(Url) ->
{error,Error}
end.


%% Parses our XML sending each tweet to parse_twitters
parse_xml(Xml,XPath) ->
Twitters = xmerl_xpath:string(XPath, Xml),
Expand All @@ -203,19 +216,6 @@ parse_twitters(Tweets,[Tweet|Twitters]) ->
parse_twitters(List,[]) ->
{ok,List}.

%% Checks to see if the user can actually log in.
auth_user(Login, Password) ->
case request_url(?VerifyUrl, Login, Password) of
{ok,Body} ->
case Body of
"<authorized>true</authorized>" -> true;
_ -> false
end;
{error,Error} ->
{error,Error}
end.


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

Expand Down

0 comments on commit dcbd78f

Please sign in to comment.