You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: twitter-http-challenge/_real_twitter_with_twitter4j.html.md
+80-4Lines changed: 80 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,85 @@ So far, the challenge involved the usage of the Codelearn Twitter API, which pro
6
6
7
7
Refer to the [Javadoc](http://twitter4j.org/en/javadoc.html) and [code examples](http://twitter4j.org/en/code-examples.html) provided by Twitter4J.
8
8
9
-
###Tasks
10
-
* Insert the relevant JAR files into your Eclipse project
11
-
* Register at [dev.twitter.com](https://dev.twitter.com) and obtain consumer key and secret for your Twitter application.
12
-
* Replace the existing HTTP network mechanisms for logging in, fetching tweets and submitting new tweets with the methods provided by Twitter4J.
9
+
For using Twitter4J library, you need to register an app at [http://dev.twitter.com/apps](http://dev.twitter.com/apps). For your convenience, we have created an app & you can use the API key & secret (reproduced below). It is a good practice to create a separate class `TwitterConstants.java` and define these as static variables to be used in your app
13
10
11
+
public static String CONSUMER_KEY = "pC3D9eMxb8pXNAPhBHAQFYLoS";
12
+
public static String CONSUMER_SECRET = "8qhOLjLHiqLQJLLQUnBNSlnUoFtbLHjWQlnaxS5W3n6NkkUeOi";
14
13
14
+
15
+
### Tasks
16
+
17
+
1) Modify MainActivity.java to have only one 'Sign in with Twitter' button . Remove the LinearLayouts containing username & password fields. Hook up the button with Twitter4J so that the user gets redirected to Twitter for authentication.
18
+
19
+
2) Our tests will not be access the webView & fill in the data. Our tests will be using @DroidChallenge user oAuth token to test your app. We need to mandate that you should store the token details in your app in **codelearn_twitter** SharedPreference with key **key_acc_token** for the token & **key_acc_token_secret** for the secret. We are simply going to write @DroidChallenge token values to these keys in the SharedPreference to test your app on our server.
20
+
21
+
**P.S. - We will not get your twitter account token details this way & the app will not post as you when run on our server. Just pause & think for a minute if you do not get it.**
22
+
23
+
It is a good practice to store these names in TwitterConstants.java
24
+
25
+
`TwitterConstants.java`
26
+
27
+
public static final String SHARED_PREFERENCE = "codelearn_twitter";
28
+
public static final String PREF_KEY_TOKEN = "key_acc_token";
29
+
public static final String PREF_KEY_SECRET = "key_acc_token_secret";
2) Once the user gets authenticated with Twitter, he should automatically go to TweetListActivity where he can see his tweets. Modify the logic so that **only new tweets are fetched & appended to the tweet list**.
41
+
42
+
3) Create a new Activity **ComposeTweetActivity** to compose a tweet. Make sure to keep the name exactly the same, also the Activity should extend normal Activity & not ActionBarActivity. A corresponding layout file **activity_compose_tweet.xml** will get generated. Replace the content of the file with the content below
4) Add a menu item on TweetListActivity to take user to ComposeTweetActivity**. Overall, there should only be two menu items - the first for Refresh of tweets, the second one for compose tweet.
0 commit comments