|
1 | | -Instructions to run the Twitter Influence Analyzer Application(Java version): |
| 1 | +# How to Run and Deploy the Twitter Influence Analyzer # |
2 | 2 | ========================================== |
3 | 3 |
|
| 4 | +## Prerequisites ## |
4 | 5 |
|
5 | | -Using the terminal/command line interface: |
6 | | ------------------------------------------- |
| 6 | +Before we begin, we first need to install the command line tool that will be used to upload and manage your application. Cloud Foundry uses a tool called [**cf**](https://github.com/cloudfoundry/cf). This tool is written in Ruby, so you must have Ruby installed. If you are running on Windows, you can install Ruby from [this](http://rubyinstaller.org/downloads/) website. |
7 | 7 |
|
8 | | -- **Prerequisites:** |
9 | | - - Before we begin, we first need to install the command line tool that will be used to upload and manage your application. Cloud Foundry uses a tool called [**cf**](https://github.com/cloudfoundry/cf). This is a Ruby application, so you must have Ruby installed. If you are running on Windows, you can install Ruby from [this](http://rubyinstaller.org/downloads/) website. |
10 | | - - For Linux systems, consult your documentation for how to install the **ruby** package - for Ubuntu the command **apt-get install ruby** should work for you. |
| 8 | +For Linux systems, consult your documentation for how to install the **ruby** package - for Ubuntu the command: |
11 | 9 |
|
12 | | - - Once Ruby is installed, cf can be installed by using the **gem install** command: |
13 | | - |
14 | | - \> **gem install cf** |
| 10 | + apt-get install ruby |
| 11 | + |
| 12 | +should work for you. |
| 13 | + |
| 14 | +Once Ruby is installed, cf can be installed by using the **gem install** command: |
15 | 15 |
|
16 | | -- **Download and Load App Into Eclipse** |
17 | | - - There are two ways to download the app and import it into Eclipse: |
18 | | - - 1. Import the Eclipse project by following these instructions: |
19 | | - - A. clone the current repository, i.e. |
20 | | - **git clone https://github.com/ibmjstart/bluemix-java-twitter-search.git** |
21 | | - - B. Open Eclipse |
22 | | - - C. Then File->Import |
23 | | - - D. Under the header labeled "General", click "Existing Projects Into Workspace" and click Next |
24 | | - - E. Click "Browse" next to the first text field, and navigate to the cloned repository and find the folder labeled "app" and click ok. |
25 | | - - F. Under Projects you should now see a project called "TwitterSearch", make sure the checkbox next to the "TwitterSearch" project is checked and then click "Finish |
26 | | - - G. You should now see the "TwitterSearch" project in your list of projects in Eclipse. |
| 16 | + gem install cf |
27 | 17 |
|
28 | | - - 2. Import the WAR File |
29 | | - - A. Navigate to https://github.com/ibmjstart/bluemix-java-sample-twitter-influence-app/releases |
30 | | - - B. Click the green button labeled "twitter_influence_analyzer.war" and that will download the WAR file. |
31 | | - - C. Open Eclipse |
32 | | - - D. Then File->Import |
33 | | - - E. Scroll down to the "Web" section, expand that section and click WAR File then click Next. |
34 | | - - F. Click next and then Finish and the project should be imported into Eclipse |
| 18 | +## Download the App ## |
35 | 19 |
|
36 | | -- **Overview of the app:** This is a Java Web(Standalone) app that uses the following cloud service: |
37 | | - - MongoDB (backend database) |
| 20 | +The source for this app is at GitHub so, for example, if you are using the command line you can clone the repository like this: |
38 | 21 |
|
39 | | -- **Download and modify app code:** |
40 | | - - **Download the app** |
41 | | - - clone the current repository, i.e. |
42 | | - **git clone https://github.com/ibmjstart/bluemix-java-sample-twitter-influence-app.git** |
| 22 | + git clone https://github.com/ibmjstart/bluemix-java-sample-twitter-influence-app.git |
| 23 | + |
| 24 | +If you want to use Eclipse to work on it, there are two ways you can get the source into Eclipse: |
43 | 25 |
|
44 | | - - **External and Public APIs:** |
| 26 | +1. Import the Eclipse project by following these instructions: |
| 27 | + 1. Start by cloning the repository, as described above |
| 28 | + 2. Open Eclipse |
| 29 | + 3. Select File->Import |
| 30 | + 4. Under the header labeled "General", click "Existing Projects Into Workspace" and click Next |
| 31 | + 5. Click "Browse" next to the first text field, and navigate to the cloned repository and find the folder labeled "app" and click ok. |
| 32 | + 6. Under Projects you should now see a project called "twitter_influence_analyzer", make sure the checkbox next to the "twitter_influence_analyzer" project is checked and then click Finish |
| 33 | + 7. You should now see the "twitter_influence_analyzer" project in your list of projects in Eclipse. |
45 | 34 |
|
46 | | - This app uses some external APIs. You need to register the app with Twitter and Klout to get the keys and tokens. |
| 35 | +2. Import the WAR File |
| 36 | + 1. Navigate to https://github.com/ibmjstart/bluemix-java-sample-twitter-influence-app/releases |
| 37 | + 2. Click the green button labeled "twitter_influence_analyzer.war" and that will download the WAR file. |
| 38 | + 3. Open Eclipse |
| 39 | + 4. Then File->Import |
| 40 | + 5. Scroll down to the "Web" section, expand that section and click WAR File then click Next. |
| 41 | + 6. Click next and then Finish and the project should be imported into Eclipse |
47 | 42 |
|
48 | | - - **Twitter v1.1 API:** |
| 43 | +This is a Java app that uses the following cloud services: |
49 | 44 |
|
50 | | - To access the Twitter API you need the consumer keys and access tokens, so you must register the app with Twitter. You can register your app [here](https://dev.twitter.com/). |
| 45 | +- Company Text Analytics Service |
| 46 | +- Name Text Analytics Service |
| 47 | +- MongoDB (backend database) |
51 | 48 |
|
52 | | - [More information on how to register the app with Twitter](registerTwitter.md) |
| 49 | +## External and Public APIs ## |
53 | 50 |
|
54 | | - - **Klout API:** |
| 51 | +This app uses some external APIs. You need to register the app with Twitter and Klout to get the keys and tokens. |
55 | 52 |
|
56 | | - You can register the app with Klout [here](http://developer.klout.com/member/). When you register with Klout, you'll get a Klout Key, which you can use to create a Klout Object as shown in the code. |
| 53 | +### Twitter v1.1 API ### |
57 | 54 |
|
58 | | - - **Google Maps v3 API:** |
| 55 | +To access the Twitter API you need the consumer keys and access tokens, so you must register the app with Twitter. You can register your app [here](https://dev.twitter.com/). |
59 | 56 |
|
60 | | - This app uses the Google Maps v3 APIs. Google APIs are open for the developers and you do not need to register the app with Google. Here's the [link](https://developers.google.com/maps/documentation/javascript/tutorial) for the Google Maps APIs. |
| 57 | +[More information on how to register the app with Twitter](registerTwitter.md) |
61 | 58 |
|
62 | | - - The twitter credentials are entered in the file called as twitter4j.properties which is present in the classpath (src directory). Just copy paste the credentials in twitter4j.properties file that you get after registering the app with twitter. Also the Klout API key is entered in the file called klout.properties present in the classpath as shown below: |
| 59 | +### Klout API ### |
63 | 60 |
|
64 | | -  |
| 61 | +You can register the app with Klout [here](http://developer.klout.com/member/). When you register with Klout, you'll get a Klout Key, which you can use to create a Klout Object as shown in the code. |
65 | 62 |
|
66 | | - - **Deploy the App:** |
| 63 | +### Google Maps v3 API ### |
67 | 64 |
|
68 | | - Now that you have included the twitter keys and tokens and klout key as shown above, you are all set to deploy the app. In the terminal, go in the directory of the app. The application is wrapped in a WAR file. You can directly deploy/push the WAR file using push command: |
| 65 | +This app uses the Google Maps v3 APIs. Google APIs are open for the developers and you do not need to register the app with Google. Here's the [link](https://developers.google.com/maps/documentation/javascript/tutorial) for the Google Maps APIs. |
69 | 66 |
|
70 | | - \> **cf push** |
| 67 | +The twitter credentials are entered in the file called as twitter4j.properties which is present in the classpath (src directory). Just copy paste the credentials in twitter4j.properties file that you get after registering the app with twitter. Also the Klout API key is entered in the file called klout.properties present in the classpath as shown below: |
71 | 68 |
|
72 | | - Just follow the instructions on the screen. You can select the default settings for deploying the app, i.e. for URL, memory reservations (512 Recommended), number of instances. You need to bind the MongoDB service to the app. |
| 69 | + |
73 | 70 |
|
74 | | - Binding a Service to Your App |
| 71 | +## Deploying the App ## |
75 | 72 |
|
76 | | - - Create the service instance and bind the service instance while deploying the app. The **cf push** command will ask, "Create services to bind to 'appname'?" Answer yes and go through the menu. See the screenshots of a sample app push below for more clarity. |
| 73 | +Once you have included the Twitter keys and tokens and Klout key as shown above, you are all set to deploy the app. In the terminal, go in the directory of the app. The application is wrapped in a WAR file. You can directly deploy/push the WAR file using push command: |
77 | 74 |
|
78 | | - Note: This app expects details of the mongoDB service to be present in the environment variables and will generate exception if you try to deploy it without first binding the service. |
| 75 | + cf push |
79 | 76 |
|
80 | | - Here are some snapshots of how one would deploy the app and create services required for the app: |
81 | | - |
82 | | -  |
| 77 | +Just follow the instructions on the screen. You can select the default settings for deploying the app, i.e. for URL, memory reservations (512 Recommended), number of instances. You need to bind the MongoDB service to the app. |
83 | 78 |
|
84 | | -  |
| 79 | +### Binding a Service to Your App ### |
85 | 80 |
|
86 | | -  |
| 81 | +For the app to function correctly, you must create the service instance and bind the service instance while deploying the app. The **cf push** command will ask, "Create services for application?" Answer yes, then you will be presented with a list of services. Choose **mongodb** from this list. Below, you can see some screenshots of what this should look like when deploying from the command line. |
87 | 82 |
|
| 83 | + |
88 | 84 |
|
89 | | - - After the application is deployed using **cf push**, you can check the status of the app using the following command: **cf apps**. If the status is RUNNING, you can hit the URL in the browser and see the application is running. |
| 85 | + |
90 | 86 |
|
| 87 | + |
91 | 88 |
|
92 | | -Troubleshooting |
93 | | ------------------------------------ |
94 | | -- Sometimes your app may not work as expected and debugging needs to be done. The cf command line tool can be used to assist with debugging. With the cf you can check your app's logs by typing the command **cf logs [app_name]** |
| 89 | +- After the application is deployed using **cf push**, you can check the status of the app using the following command: **cf apps**. If the status is RUNNING, you can hit the URL in the browser and see the application is running. |
95 | 90 |
|
96 | | -- When you first start using the cf tool, you may potentially have trouble logging in due to no target being set. To view the target that is set, type **cf target** and if you want to set a new target type **cf target [target_url]**. Note: The target URL will usually be in the form of http://api.xxx.tld |
| 91 | +## Troubleshooting ## |
97 | 92 |
|
| 93 | +- Sometimes your app may not work as expected and debugging needs to be done. The cf command line tool can be used to assist with debugging. With the cf you can check your app's logs by typing the command **cf logs [app_name]** |
| 94 | +- When you first start using the cf tool, you may potentially have trouble logging in due to no target being set. To view the target that is set, type **cf target** and if you want to set a new target type **cf target [target_url]**. Note: The target URL will usually be in the form of http://api.xxx.tld |
98 | 95 | - From time to time your app may stop working, this means it could require a restart. To do this you must first stop it by typing **cf stop**. Once the app has been stopped, you can type **cf start** and if there are no other problems your app should start. |
99 | 96 |
|
| 97 | +## Screenshots ## |
100 | 98 |
|
101 | | -Some screen-shots of the running app |
102 | | ------------------------------------- |
103 | | - |
104 | | -- This is the home screen of the app. You can enter a twitter screen name in the text box and click the Analyze button to see their influence. You can also view any records saved in the database by clicking on the 'View Database' button. |
105 | | - |
106 | | -  |
| 99 | +This is the home screen of the app. You can enter a twitter screen name in the text box and click the Analyze button to see their influence. You can also view any records saved in the database by clicking on the 'View Database' button. |
107 | 100 |
|
108 | | -- After entering the twitter name and clicking the Analyze button, you'll be able to see the influence analysis of that person on the left side. You will also see their last 10 tweets and any recent mentions in the tweets plotted on Google Maps (if there is geolocation data for a tweet). |
| 101 | + |
109 | 102 |
|
110 | | -  |
| 103 | +After entering the twitter name and clicking the Analyze button, you'll be able to see the influence analysis of that person on the left side. You will also see their last 10 tweets and any recent mentions in the tweets plotted on Google Maps (if there is geolocation data for a tweet). |
111 | 104 |
|
112 | | -- These are the records of the Influencers in the database. The user can also delete the records. |
| 105 | + |
113 | 106 |
|
114 | | -  |
| 107 | +These are the records of the Influencers in the database. The user can also delete the records. |
115 | 108 |
|
| 109 | + |
0 commit comments