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
Contributor
surajkushwaha
Posts: 25
Registered: ‎01-18-2012
My Device: Blackberry curve

Facebook integration

Hello friends,

 

I ma new in integrating the facebook into the application.

So please make me step by step process to add the jar file and use it into the app.

I had already downloaded the jar facebook sdk and  add it to my workspace but I did get way how to use it.

 

I am using Blackberry JDE 5.0 for development

 

thanks in advance.

Developer
madiha
Posts: 107
Registered: ‎05-26-2011
My Device: Torch

Re: Facebook integration

below is the code i used for facebook integration in my app ... you can add the jar using add jar option in your project properties-> java build path -> libraries

 

private static String APPLICATION_ID = "";
    private static String APPLICATION_SECRET = "";
private static User user;
    private static String[] PERMISSIONS = Facebook.Permissions.ALL_PERMISSIONS;

private static Facebook fb;

static {
        try {
            accessToken = new StringBuffer(new HttpClient().doGet(
                    "https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id="
                            + APPLICATION_ID + "&client_secret=" + APPLICATION_SECRET).toString()
                    .substring(13));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }// =
    }

ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID,
                APPLICATION_SECRET, PERMISSIONS);

        fb = Facebook.getInstance(as);
        fb.setAccessToken(accessToken.toString());

 

try {

            fb.getCurrentUser(new BasicAsyncCallback() {

                public void onComplete(com.blackberry.facebook.inf.Object[] objects,
                        final java.lang.Object state) {
                    user = (User) objects[0];
                    StringBuffer post = new StringBuffer("");
                    post.append("hi:");
                    user.publishStatus(post.toString());
          
                          
                }

                public void onException(final Exception e, final java.lang.Object state) {
                    e.printStackTrace();
                    exception = true;
                    Logger.getInstance().logInformationEvent("fb exception " + e.toString());

                }
            });
        } catch (FacebookException e) {
            e.printStackTrace();
            exception = true;
        } catch (Exception e) {
            Logger.getInstance().logInformationEvent("fb exception " + e.toString());

        }

Contributor
surajkushwaha
Posts: 25
Registered: ‎01-18-2012
My Device: Blackberry curve

Re: Facebook integration

Hello friend,

 

thanks again.But  as i already mention that I am working over Blackberry JDE 5.0 so please support me over that thanks again

Developer
MohammedAziz
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold

Re: Facebook integration

Hi Madiha

 

As you said I downloaded the jar files and added it to my project...

 

Now can you please explain me in detail the next steps to integrate facebook in my application

 

Thankx in Advance...................

warm regards
Mohammed Aziz
Contributor
surajkushwaha
Posts: 25
Registered: ‎01-18-2012
My Device: Blackberry curve

Re: Facebook integration

Hello friends,

 

I had the same question for Blackberry JDE 5.0 .

thanks

in advance

 

 

regards 

suraj

 

Developer
madiha
Posts: 107
Registered: ‎05-26-2011
My Device: Torch

Re: Facebook integration

Just add a class in your project and the above code i provided (is for changing your status) then call it where you want

Developer
MohammedAziz
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold

Re: Facebook integration

there are some compile time errors in your code

1) accessToken = new StringBuffer(new HttpClient().doGet(
"https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id="
+ APPLICATION_ID + "&client_secret=" + APPLICATION_SECRET).toString()
.substring(13));

add connection factory in new HttpClient()

what is nextURl
and wnat is exception here?
warm regards
Mohammed Aziz
Contributor
surajkushwaha
Posts: 25
Registered: ‎01-18-2012
My Device: Blackberry curve

Re: Facebook integration

Helllo friends

I am getting the exception poped as screen.

message ="Classes are not found"

thnkas in advance

 

Developer
madiha
Posts: 107
Registered: ‎05-26-2011
My Device: Torch

Re: Facebook integration

private static String NEXT_URL = "http://www.facebook.com/connect/login_success.html";

 

you can do srtandard http get request to the url ...

 

Developer
MohammedAziz
Posts: 139
Registered: ‎02-23-2012
My Device: Blackberry bold

Re: Facebook integration

hi madiha

If you dont mind can you please post the class that is running

I am gettting lot of compile time errors

Like you used a "exception" variable

etc

Please post that class code

Thank you
warm regards
Mohammed Aziz