Skip to content

Commit 7b2f92e

Browse files
committed
Update TwitterPopularTags.scala
1 parent 5931819 commit 7b2f92e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/main/scala/TwitterPopularTags.scala

+11-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ object TwitterPopularTags {
2121
val (master, filters) = (args(0), args.slice(5, args.length))
2222

2323
// Twitter Authentication credentials
24-
System.setProperty("twitter4j.oauth.consumerKey", args(1))
25-
System.setProperty("twitter4j.oauth.consumerSecret", args(2))
26-
System.setProperty("twitter4j.oauth.accessToken", args(3))
27-
System.setProperty("twitter4j.oauth.accessTokenSecret", args(4))
24+
val configKeys = List("consumerKey", "consumerSecret", "accessToken", "accessTokenSecret")
25+
26+
val map = configKeys.zip(args.slice(1, 5).toList).toMap
27+
28+
configKeys.foreach(key => {
29+
if (!map.contains(key)) {
30+
throw new Exception("Error setting OAuth authenticaion - value for " + key + " not found")
31+
}
32+
val fullKey = "twitter4j.oauth." + key
33+
System.setProperty(fullKey, map(key))
34+
})
2835

2936

3037

0 commit comments

Comments
 (0)