Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
Danishr
Posts: 5
Registered: 10-31-2011
My Carrier: TATA DOCOMO

Facing problem on posting a status on Twitter

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-Development/Twiiter-Status-Update-Code-for-those-who-wan...

 

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

Please use plain text.
Developer
maadani
Posts: 552
Registered: 05-04-2011

Re: Facing problem on posting a status on Twitter

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

 


Please use plain text.
New Contributor
Danishr
Posts: 5
Registered: 10-31-2011
My Carrier: TATA DOCOMO

Re: Facing problem on posting a status on Twitter

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
&#2325;&#2360;
&#2346;&#2381;
&#2352;&#2351;
&#2366;&#2319;
</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.

Please use plain text.
Developer
pankajace12
Posts: 93
Registered: 04-30-2011
My Carrier: Airtel

Re: Facing problem on posting a status on Twitter

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

Please use plain text.
New Contributor
AdiWijaya
Posts: 4
Registered: 04-11-2012
My Carrier: Xl

Re: Facing problem on posting a status on Twitter

Same here... any suggestion? or link to solve?

Please use plain text.