Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 5
Registered: ‎10-31-2011
My Device: Curve 9300 3G
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

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

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

 


New Contributor
Posts: 5
Registered: ‎10-31-2011
My Device: Curve 9300 3G
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.

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
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

New Contributor
Posts: 4
Registered: ‎04-11-2012
My Device: 8900
My Carrier: Xl

Re: Facing problem on posting a status on Twitter

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

Highlighted
Contributor
Posts: 23
Registered: ‎10-17-2011
My Device: 9700
My Carrier: NA

Re: Facing problem on posting a status on Twitter

Hi pawan ,
ur code is working very fine , but i am facing the problem with PIN , in ur code where we mention that pin so tht i can proceed for my application. Please help me on this

Regards
Amma