Facebook oAuth implementation for blackberry

2019-08-19 02:34发布

I am working on a blackberry native application, which uses the features like Facebook and twitter sharing of messages. After goggling I found that I could make use of Facebook SDK in order to integrate with Facebook service.

I have downloaded the SDK from this link https://sourceforge.net/projects/facebook-bb-sdk/

I have followed the steps that are being explained in the README pdf file, which was bundled with SDK. I have followed the below steps

Step1: Getting Facebook façade instance

String NEXT_URL = "http://www.facebook.com/connect/login_success.html"; 
String APPLICATION_ID = "15355516805e272"; // my app id
String APPLICATION_SECRET = "354f91a79c8fe5a8de9d65b55ef9aada"; // my app secret key 
String[] PERMISSIONS = Facebook.Permissions.USER_DATA_PERMISSIONS; 

ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID, 
APPLICATION_SECRET, PERMISSIONS); 
Facebook fb = Facebook.getInstance(as);

Step2: Retrieving current user

fb.getCurrentUser(new BasicAsyncCallback() { 

        public void onComplete(com.blackberry.facebook.inf.Object[] 
objects, final java.lang.Object state) { 
          user = (User) objects[0]; 
          // do whatever you want 
        } 

        public void onException(final Exception e, final 
java.lang.Object state) { 
          e.printStackTrace(); 
          // do whatever you want 
        } 

});

Step3: Publish user status.

user.publishStatus("Hello world!"); 

But, it gives IOException and nothing happens. I am sure many people have done similar things earlier. I am looking for a source explains step by step process of integrating with Facebook service.

2条回答
别忘想泡老子
2楼-- · 2019-08-19 02:59

This code works for me. it shows how to get the current user and publish status

public class FacebookHelper {

private final String NEXT_URL = "http://www.facebook.com/connect/login_success.html";
private final String APPLICATION_ID = "123456789";
private final String APPLICATION_SECRET = "123456789123456789123456789123456789";
String[] PERMISSIONS = Facebook.Permissions.PUBLISHING_PERMISSIONS;
User user;
Facebook fb;
ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID,
        APPLICATION_SECRET, PERMISSIONS);

public  FacebookHelper() {
    fb = Facebook.getInstance(as);
}

public void publishContent(final String content) {
    try {
        fb.getCurrentUser(new BasicAsyncCallback() {
            public void onComplete(
                    com.blackberry.facebook.inf.Object[] objects,
                    final java.lang.Object state) {
                user = (User) objects[0];
                user.publishStatus(content);  
            }

            public void onException(final Exception e,
                    final java.lang.Object state) { 
                System.out.println("Exception inside BasicAsyncCallback " + e.toString()
                        + " , " + e.getMessage());
            }
        });
    } catch (Exception e) {
        System.out.println("Exception in publishContent " + e.toString() + " , "
                + e.getMessage());
    }
}
}
查看更多
乱世女痞
3楼-- · 2019-08-19 03:17

I have recently implemented Facebook & Twitter Integration into my Blackberry 7 Based Application. What i Found with this, Facebook API having Errors and even it is in Beta version.Please try Following API: FacebookAPIMe and TwitterAPIMe. If you have any problem in implementing this APIs, i will help you.Both are Simple to Use and Easily integrated with your application.Both are Containing Example App so You can also view Demo of that API.

查看更多
登录 后发表回答