Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
Ranch Hand
Posts: 1574
13
  • 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: 59700
187
  • 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: 69
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: 1574
13
  • 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: 1574
13
  • 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: 59700
187
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!