10-22-2012 03:40 AM
10-22-2012 03:42 AM
10-22-2012 03:45 AM
10-22-2012 03:47 AM
10-22-2012 03:48 AM
10-22-2012 03:53 AM - edited 10-22-2012 03:54 AM
HI Babakar,
I don't know why it is happening at ur end.
I have not face this issue at my end.
please give me TwitterScreen.java class
Thanks
10-22-2012 03:54 AM
package app.screen;
import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import com.twitterapime.rest.Credential;
import com.twitterapime.xauth.Token;
import com.twitterapime.xauth.ui.OAuthDialogListener;
import com.twitterapime.xauth.ui.OAuthDialogWrapper;
import com.twitterpawan.activity.TweetGeoLocation;
import com.twitterpawan.activity.TweetToFriend;
public class TwitterScreen extends MainScreen {
private final String CONSUMER_KEY ="84dMabefkTHVRhRnTZHFCA";
private final String CONSUMER_SECRET = "CEPGbE8qe0t6rGfoDskksrjlRhCyp9Mz1m4zi3KBc";
private final String CALLBACK_URL ="http://Jaww.fm";
private LabelField _labelStutus;
private OAuthDialogWrapper pageWrapper = null;
public StoreToken _tokenValue;
ShowAuthBrowser showAuthBrowserScreen;
public TwitterScreen()
{
setTitle("Twitter Integration using OAuth");
showAuthBrowserScreen = new ShowAuthBrowser();
add ( new ButtonField("Tweet" ) {
protected boolean navigationUnclick(int status, int time) {
_tokenValue = StoreToken.fetch();
if(_tokenValue.token.equalsIgnoreCase("nothing"))
{
showAuthBrowserScreen.doAuth( null );
UiApplication.getUiApplication().pushScreen(showAu thBrowserScreen);
}
else
{
/************************************************* ***********/
Token t = new Token(_tokenValue.token, _tokenValue.secret,
_tokenValue.userId, _tokenValue.username);
Credential c = new Credential(CONSUMER_KEY, CONSUMER_SECRET, t);
TweetGeoLocation tgl = new TweetGeoLocation();
String message="Geo Location.....";
boolean done=false;
done=tgl.doShareLocation(message, c);
if(done == true)
{
Dialog.alert("Location Tweet successfully");
}
else
{
Dialog.alert( "your location is not tweet." );
}
/************************************************* ***********/
}
return true;
}
});
}
class ShowAuthBrowser extends MainScreen implements OAuthDialogListener
{
BrowserField b = new BrowserField();
public ShowAuthBrowser()
{
_labelStutus = new LabelField("Your app is being authorize." );
add(_labelStutus );
add(b);
pageWrapper = new BrowserFieldOAuthDialogWrapper(b,CONSUMER_KEY,CONS UMER_SECRET,CALLBACK_URL,this);
pageWrapper.setOAuthListener(this);
}
public void doAuth( String pin )
{
try
{
if ( pin == null )
{
pageWrapper.login();
}
else
{
this.deleteAll();
add(b);
pageWrapper.login( pin );
}
}
catch ( Exception e )
{
final String message = "Error loggin Twitter: " + e.getMessage();
Dialog.alert( message );
}
}
public void onAccessDenied(String response ) {
System.out.println("Access denied! -> " + response );
updateScreenLog( "Acceso denegado! -> " + response );
}
public void onAuthorize(final Token token) {
final Token myToken = token;
_tokenValue = StoreToken.fetch();
_tokenValue.token = myToken.getToken();
_tokenValue.secret = myToken.getSecret();
_tokenValue.userId = myToken.getUserId();
_tokenValue.username = myToken.getUsername();
_tokenValue.save();
UiApplication.getUiApplication().invokeLater( new Runnable() {
public void run() {
deleteAll();
Credential c = new Credential(CONSUMER_KEY, CONSUMER_SECRET, myToken);
TweetToFriend tw = new TweetToFriend();
String message="";
boolean done=false;
done=tw.doTweet(message, c);
if(done == true)
{
Dialog.alert( "Tweet succusfully..." );
close();
}
}
});
}
public void onFail(String arg0, String arg1) {
updateScreenLog("Error authenticating user! -> " + arg0 + ", " + arg1);
}
}
private void updateScreenLog( final String message )
{
UiApplication.getUiApplication().invokeLater( new Runnable() {
public void run() {
_labelStutus.setText( message );
}
});
}
}
10-22-2012 04:34 AM - edited 10-22-2012 04:35 AM
HI
check ur tweet on website. is there any tweet?
Thanks
Pawan
10-22-2012 04:35 AM
10-22-2012 04:38 AM