#INSTALLATION GUIDE
The project contains 2 files:
- TwitterAPI_Core.pm (Core files to call Twitter APIs)
- TwitterAPI_Web.pl (Web application using REST APIs)
Both the files should be present in the same directory.
Pre-requisites to deploy and run the application:
Latest perl edition and openssl should be installed. In order to install the prerequisites, run cpan <module_name> (as mentioned below):
- Mojolicious
- HTTP::Request::Common
- HTTP::Headers
- Readonly
- LWP::UserAgent
- Crypt::SSLeay
To deploy, run the following command:
perl TwitterAPI_Web.pl daemon
To try on public server, go to:
http://54.201.18.204/ (hosted on AWS)
#API DOCUMENTATION
##GET latesttweets
Returns a collection of the most recent tweets posted by the user indicated by the screen_name, in a chronological order. This method returns up to 200 of the user’s most recent tweets. These do not include retweets.
URL: /latesttweets
Parameters:
-
Screen_name: The screen_name of the user for whom to return the most recent tweets.
- Example value: njain27
- Required: YES
-
Count: Number of the most recent tweets to return for the given user.
- Maximum: 200
- Required: NO
- Default: 10.
Example Request: /latesttweets?screen_name=njain27&count=5
##GET followsintersection
Returns a collection of the common users followed by the two user indicated by the screen_name.
URL: /followsintersection
Parameters:
- Screen_name: The two screen_name of the users for whom to return the common friends.
- Example value: prateekgupta87,njain27
- Required: YES. Exact two.
Example Request: / followsintersection?screen_name=prateekgupta87,njain27
Adding more API methods:
- Create a new method in TwitterAPI_Core.pm.
- If accessToken doesn’t exist, call method getAccessToken() to fetch accessToken
- Return result in JSON format
- Raise exception when the response is not 200 from Twitter API requests.
- Add another condition in the TwitterAPI_web.pl to specify URL action.
- Read the parameters and call the new method.
- Return JSON result and catch exception, if any.
- Read error string from the method getErrorString by passing Exception string as parameter.
- Add any new exception to the getErrorString method, to give user friendly error messages.