Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Twitter4J code examples ... what is args[0]?  RSS feed

 
Ranch Hand
Posts: 1537
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the source code examples, here: http://twitter4j.org/en/code-examples.html

The code does things like "Status status = twitter.updateStatus(args[0]);"

But, it's not clear what args[0] is or is expected to be in the main methods since there isn't a complete example.

I think I almost have it all working, but obviously this is a critical piece.

Thanks in advance for suggestions.

-- mike
 
Marshal
Posts: 58830
179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the parameter type for that updateStatus() method? What values does it take? I would have thought that the documentation should explain that.
The argument args[0] usually refers to the first element of a String[], and an array of that type, but often empty, is passed from the OS at the command line/terminal to the main method. I don't know any more than that.
 
Ranch Hand
Posts: 50
3
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, one should read all the code: part 7 and 9 contain three complete compileable examples - and as they have a main(args) so args[0] refer to the first cli argument.
 
Mike London
Ranch Hand
Posts: 1537
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matt Wong wrote:Well, one should read all the code: part 7 and 9 contain three complete compileable examples - and as they have a main(args) so args[0] refer to the first cli argument.



No need to be snotty. Keep it nice, OK? Clearly I missed that.

Thanks for your reply.

- mike
 
Mike London
Ranch Hand
Posts: 1537
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:What is the parameter type for that updateStatus() method? What values does it take? I would have thought that the documentation should explain that.
The argument args[0] usually refers to the first element of a String[], and an array of that type, but often empty, is passed from the OS at the command line/terminal to the main method. I don't know any more than that.



The documentation is not really clear. The examples' oAuth code compiles but even this code fails to work.

I get: Exception in thread "main" java.lang.IllegalStateException: Access token already available.

----

The problem could definitively be on my side, but it's basically just the oAuth that I have to get past.

In the code below, I now pass the consumer key and the consumer secret key to the program as the first two arguments.

The code fails on the line below RequestToken requestToken = twitter.getOAuthRequestToken();

This code is right out of the examples folder from twitter4j. The only change I made was to add a "filename" variable for the properties file.

Would really appreciate any ideas why this is failing.

Thanks,

- mike


/*
 
Campbell Ritchie
Marshal
Posts: 58830
179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike London wrote:. . . No need to be snotty. . . .

Agree. We shall keep an eye on that user. Well done standing up for yourself
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!