10-31-2011 08:54 AM
Hello BlackBerry Support Team,
I am facing a problem to post a status on Twitter. I am using a source provided on http://supportforums.blackberry.com/t5/Java-Develo
I am using Eclipse BB plugin 1.1 and BB JRE 5.0
My code is
public void run() {
String res;
TwiiterSettings.getInstance().init("< my consumer key>", "<my Consumer secret>");
TwitterConnect tweet = new TwitterConnectImpl();
try {
tweet = new TwitterConnectImpl();
response = tweet.requestToken(<my password> , <my userName>);
res = null;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
Dialog.alert("UnsupportedEncodingException");
} catch (CryptoTokenException e) {
e.printStackTrace();
} catch (CryptoUnsupportedOperationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Dialog.alert("" + response);
res = tweet.statusUpdate( response , "Hello new ");
if(res.indexOf("in_reply_to_status_id") > -1) {
Dialog.alert("Status updated successfully");
}
if (res.indexOf("duplicate") > -1) {
Dialog.alert("Duplicate status");
}
}I am getting "Array index out of bound exception" at line String secret = StringUtil.split(tokens[1], '=')[1]; in Token.java class. My consumer key and consumer secret is correct and I am posting my status with my personal account. I am stuck with this problem for last one week. I also tried Ksoap2.jar and twitter_api_me-1.6 but in eclipse it shows me "Module not found error". I also tried to put source instead of jar file in my project source folder but I am unable to find Ksoap2 source code. Please suggest me where I am wrong to achieve this.
I will be highly obliged for your kind co-operation.
Waiting for your early response.
Regards,
Danish Raza
10-31-2011 11:06 AM
Hi Danish Raza,
I haven't got a look in the source code, but what do you get when you try to print out:
1. tokens.length
2. (StringUtil.split(tokens[1], '=')).length
11-01-2011 01:40 AM
Thanks a lot for your quick reply,
As you suggested me to print out (StringUtil.split(tokens[1], '=')).length. I am doing so but this line gives me Array out of bound index exception. Reason behind my tokens[1] contain the value #2325; and (StringUtil.split(tokens[1], '=')) unable to split it. My tokens.length gives me 48 size. Is there anything wrong with my access token string? My access token String is as follows
<?xml version="1.0" encoding="UTF-8"?> <hash> <error>XAuth कस प् रय ाए
</error> <request>/oauth/access_token</request> </hash>
Can you please tell me what is the format of a token secret. If i try to print tokens[1] it gives me #2325; is it token secret? Please correct me if I am wrong.
Please look into problem and suggest me what to do next. I am waiting for your valuable fedback.
Thanks a lot once again.
02-09-2012 05:55 AM
Hi Danish,
I am having the same problem as u. Array index out of bound.
If u have resolve the issue, so pls suggest me.
Thanks
Pawan Jha
04-24-2012 11:26 PM
Same here... any suggestion? or link to solve?