diff options
author | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-04-23 16:08:08 +0200 |
---|---|---|
committer | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-04-23 16:08:08 +0200 |
commit | ab095e0ecbe63dc19f4de69872b14aee921bba6b (patch) | |
tree | 06700cb7a9f62a55f439f14d21584cc8356489a7 /src/Chapter2 | |
parent | 14d7547cd31c5be878e377a4a5370f604c8d59d4 (diff) | |
download | TwitterDataAnalytics-ab095e0ecbe63dc19f4de69872b14aee921bba6b.tar.gz |
Renamed OAuthUtils to Configuration class.
Diffstat (limited to 'src/Chapter2')
-rw-r--r-- | src/Chapter2/openauthentication/OAuthExample.java | 10 | ||||
-rw-r--r-- | src/Chapter2/restapi/RESTApiExample.java | 2 | ||||
-rw-r--r-- | src/Chapter2/restapi/RESTSearchExample.java | 4 | ||||
-rw-r--r-- | src/Chapter2/streamingapi/StreamingApiExample.java | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/src/Chapter2/openauthentication/OAuthExample.java b/src/Chapter2/openauthentication/OAuthExample.java index 9b2ec7a..34ca3a1 100644 --- a/src/Chapter2/openauthentication/OAuthExample.java +++ b/src/Chapter2/openauthentication/OAuthExample.java @@ -16,7 +16,7 @@ import oauth.signpost.exception.OAuthCommunicationException; import oauth.signpost.exception.OAuthExpectationFailedException; import oauth.signpost.exception.OAuthMessageSignerException; import oauth.signpost.exception.OAuthNotAuthorizedException; -import utils.OAuthUtils; +import utils.Configuration; public class OAuthExample { @@ -24,18 +24,18 @@ public class OAuthExample { try { //consumer key for Twitter Data Analytics application - if(OAuthUtils.CONSUMER_KEY.isEmpty()) + if(Configuration.CONSUMER_KEY.isEmpty()) { System.out.println("Register an application and copy the consumer key into the configuration file."); return null; } - if(OAuthUtils.CONSUMER_SECRET.isEmpty()) + if(Configuration.CONSUMER_SECRET.isEmpty()) { System.out.println("Register an application and copy the consumer secret into the configuration file."); return null; } - OAuthConsumer consumer = new CommonsHttpOAuthConsumer(OAuthUtils.CONSUMER_KEY,OAuthUtils.CONSUMER_SECRET); - OAuthProvider provider = new DefaultOAuthProvider(OAuthUtils.REQUEST_TOKEN_URL, OAuthUtils.ACCESS_TOKEN_URL, OAuthUtils.AUTHORIZE_URL); + OAuthConsumer consumer = new CommonsHttpOAuthConsumer(Configuration.CONSUMER_KEY,Configuration.CONSUMER_SECRET); + OAuthProvider provider = new DefaultOAuthProvider(Configuration.REQUEST_TOKEN_URL, Configuration.ACCESS_TOKEN_URL, Configuration.AUTHORIZE_URL); String authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND); System.out.println("Now visit:\n" + authUrl + "\n and grant this app authorization"); System.out.println("Enter the PIN code and hit ENTER when you're done:"); diff --git a/src/Chapter2/restapi/RESTApiExample.java b/src/Chapter2/restapi/RESTApiExample.java index 9ceb88b..3d6074b 100644 --- a/src/Chapter2/restapi/RESTApiExample.java +++ b/src/Chapter2/restapi/RESTApiExample.java @@ -48,7 +48,7 @@ public class RESTApiExample */ public OAuthConsumer GetConsumer() { - OAuthConsumer consumer = new DefaultOAuthConsumer(utils.OAuthUtils.CONSUMER_KEY,utils.OAuthUtils.CONSUMER_SECRET); + OAuthConsumer consumer = new DefaultOAuthConsumer(utils.Configuration.CONSUMER_KEY,utils.Configuration.CONSUMER_SECRET); consumer.setTokenWithSecret(OAuthTokens.getAccessToken(),OAuthTokens.getAccessSecret()); return consumer; } diff --git a/src/Chapter2/restapi/RESTSearchExample.java b/src/Chapter2/restapi/RESTSearchExample.java index 510661c..e9a5dd7 100644 --- a/src/Chapter2/restapi/RESTSearchExample.java +++ b/src/Chapter2/restapi/RESTSearchExample.java @@ -43,7 +43,7 @@ public class RESTSearchExample */ public OAuthConsumer GetConsumer() { - OAuthConsumer consumer = new DefaultOAuthConsumer(utils.OAuthUtils.CONSUMER_KEY,utils.OAuthUtils.CONSUMER_SECRET); + OAuthConsumer consumer = new DefaultOAuthConsumer(utils.Configuration.CONSUMER_KEY,utils.Configuration.CONSUMER_SECRET); consumer.setTokenWithSecret(OAuthTokens.getAccessToken(), OAuthTokens.getAccessSecret()); return consumer; } @@ -138,7 +138,7 @@ public class RESTSearchExample URL url = new URL("https://api.twitter.com/1.1/application/rate_limit_status.json"); HttpURLConnection huc = (HttpURLConnection) url.openConnection(); huc.setReadTimeout(5000); - OAuthConsumer consumer = new DefaultOAuthConsumer(utils.OAuthUtils.CONSUMER_KEY,utils.OAuthUtils.CONSUMER_SECRET); + OAuthConsumer consumer = new DefaultOAuthConsumer(utils.Configuration.CONSUMER_KEY,utils.Configuration.CONSUMER_SECRET); consumer.setTokenWithSecret(OAuthTokens.getAccessToken(), OAuthTokens.getAccessSecret()); consumer.sign(huc); huc.connect(); diff --git a/src/Chapter2/streamingapi/StreamingApiExample.java b/src/Chapter2/streamingapi/StreamingApiExample.java index 8abfff4..61a9cc0 100644 --- a/src/Chapter2/streamingapi/StreamingApiExample.java +++ b/src/Chapter2/streamingapi/StreamingApiExample.java @@ -38,7 +38,7 @@ import org.apache.http.params.CoreConnectionPNames; import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; -import utils.OAuthUtils; +import utils.Configuration; public class StreamingApiExample { @@ -73,7 +73,7 @@ public class StreamingApiExample HttpClient httpClient = new DefaultHttpClient(); httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(90000)); //Step 1: Initialize OAuth Consumer - OAuthConsumer consumer = new CommonsHttpOAuthConsumer(OAuthUtils.CONSUMER_KEY,OAuthUtils.CONSUMER_SECRET); + OAuthConsumer consumer = new CommonsHttpOAuthConsumer(Configuration.CONSUMER_KEY,Configuration.CONSUMER_SECRET); consumer.setTokenWithSecret(OAuthToken.getAccessToken(),OAuthToken.getAccessSecret()); //Step 2: Create a new HTTP POST request and set parameters HttpPost httppost = new HttpPost(baseUrl); |