BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Help with Blackberry and Twitter integration (http://www.blackberryforums.com/developer-forum/257260-help-blackberry-twitter-integration.html)

kelospario 01-26-2012 01:12 PM

Help with Blackberry and Twitter integration
 
Im developing an application that should to be able to share contents to twitter, and i cant get OAuth to work.
Im trying with the library twitter_api_me-1.8.jar and the example TwitterAPIME-RIM-OAuthSample.

The problem i think is in the callback, because im able to open the twitter login page and login, but after that i dont know how to get back to the application, and the method public void onAuthorize(Token token) is never invoked.


Ive been searching this in google and i found that a lot of people had the same problem, but unfortunately i didnt find any solution.

Thanks to all.


Here is my source code:
package com.twitterapime.oauth;

import impl.rim.com.twitterapime.xauth.ui.BrowserContentM anagerOAuthDialogWrapper;
import net.rim.device.api.browser.field.BrowserContentMan ager;
import net.rim.device.api.browser.field.RenderingOptions;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;

import com.twitterapime.rest.Credential;
import com.twitterapime.rest.TweetER;
import com.twitterapime.rest.UserAccountManager;
import com.twitterapime.search.Tweet;
import com.twitterapime.xauth.Token;
import com.twitterapime.xauth.ui.OAuthDialogListener;
import com.twitterapime.xauth.ui.OAuthDialogWrapper;

public class TwitterAPIMERIMOauthSample extends UiApplication {
/**
* @param args
*/
public static void main(String[] args) {
TwitterAPIMERIMOauthSample app = new TwitterAPIMERIMOauthSample();
app.enterEventDispatcher();
}

/**
*
*/
public TwitterAPIMERIMOauthSample() {
pushScreen(new BrowserFieldScreen());
}
}

/**
*/
class BrowserFieldScreen extends MainScreen{
/**
*
*/
private final String CONSUMER_KEY = "<consumer key>";

/**
*
*/
private final String CONSUMER_SECRET = "<consumer secret>";

/**
*
*/
public static final String CALLBACK_URL= "";

/**
*
*/
public BrowserFieldScreen() {
setTitle("Twitter API ME - OAuth");
BrowserContentManager browserMngr = new BrowserContentManager(0);
RenderingOptions rendOptions = browserMngr.getRenderingSession().getRenderingOpti ons();
rendOptions.setProperty(
RenderingOptions.CORE_OPTIONS_GUID,
RenderingOptions.SHOW_IMAGES_IN_HTML,
false);
//
add(browserMngr);
//
OAuthDialogWrapper pageWrapper =
new BrowserContentManagerOAuthDialogWrapper(browserMng r);
//
pageWrapper.setConsumerKey(CONSUMER_KEY);
pageWrapper.setConsumerSecret(CONSUMER_SECRET);
pageWrapper.setCallbackUrl(CALLBACK_URL);
pageWrapper.setOAuthListener(new OAuthDialogListener() {

public void onAuthorize(Token token) {
Credential c = new Credential(CONSUMER_KEY, CONSUMER_SECRET, token);
UserAccountManager uam = UserAccountManager.getInstance(c);
//
try {
if (uam.verifyCredential()) {
TweetER.getInstance(uam).post(new Tweet("test: " + System.currentTimeMillis()));
//
System.out.println("Tweet posted!");
}
} catch (Exception e) {
System.out.println("Error by posting tweet.");
}
}

/**
* @see com.twitterapime.xauth.ui.OAuthDialogListener#onAc cessDenied(java.lang.String)
*/
public void onAccessDenied(String message) {
System.out.println("Access denied!");
}

/**
* @see com.twitterapime.xauth.ui.OAuthDialogListener#onFa il(java.lang.String,
* java.lang.String)
*/
public void onFail(String error, String message) {
System.out.println("Error by authenticating user!");
}

});
//
pageWrapper.login();
}

}

erAjayGoyal 05-31-2012 12:13 AM

Re: Help with Blackberry and Twitter integration
 
I'm also getting same problem, getting twitter login page, after sucessfull login its display pin number, after that what i have to do, dont know, where i've to used that pin number, no idea, i have searched alot on google, but didn't find out any solution yet, If anyone solved out please hepls me also, it would be appericated.

Thnaks
Ajay


All times are GMT -5. The time now is 09:24 PM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.