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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

Posts: 107
Registered: ‎05-26-2011
My Device: Torch
My Carrier: Mobilink

Re: Facebook integration

public class FacebookIntegration {

    private static User user;

    private static String APPLICATION_ID = "";
    private static String APPLICATION_SECRET = "";

    private static String[] PERMISSIONS = Facebook.Permissions.ALL_PERMISSIONS;

    private static String[] prayerNames = { "Tahajud", "Fajr", "Shuruq", "Duhr", "Asr", "Maghrib",
            "Isha" };
    public static boolean posted = false;
    private static SharePopup _obj;
    public static boolean exception = false;
    static Facebook fb;
    private static StringBuffer accessToken;
    static {
        try {
            accessToken = new StringBuffer(new HttpClient().doGet(
                            + APPLICATION_ID + "&client_secret=" + APPLICATION_SECRET).toString()
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }// =
    private static String NEXT_URL = "http://www.facebook.com/connect/login_success.html";

    // private static String NEXT_URL = "http://m.facebook.com/wall.php";

    public static boolean integrate(SharePopup obj) {

        _obj = obj;
        ApplicationSettings as = new ApplicationSettings(NEXT_URL, APPLICATION_ID,

        fb = Facebook.getInstance(as);


        try {

            user = fb.getCurrentUser();

        } catch (FacebookException e1) {

            exception = true;
        // if (!exception) {
        try {

            fb.getCurrentUser(new BasicAsyncCallback() {

                public void onComplete(com.blackberry.facebook.inf.Object[] objects,
                        final java.lang.Object state) {
                    FacebookIntegration.this.user = (User) objects[0];
                    Vector prayerTimes = (Vector) PrayerTimesDTO.getPrayerTimes();
                    String location = "Makkah";

                    SettingsDTO settings = (SettingsDTO) SettingsDTO.getSettings();

                    // if (settings != null &&
                    // settings.isGPS&&Constants.qualifiedCoordinates!=null){
                    // RecordStoreUtility rs =
                    // RecordStoreUtility.getRecordStore();
                    // rs.openRecord(RecordStoreUtility.CITY_GPS_REC_STORE);
                    // location = rs.readCityGps();
                    // rs.closeRecord();
                    // } else
                    if (Utility.readLocation()) {
                        RecordStoreUtility rs = RecordStoreUtility.getRecordStore();
                        location = rs.readCityName();


                    StringBuffer post = new StringBuffer("");
                    post.append("Location: " + location + " \n" + "Prayer Times:");
                    for (int i = 0; i < prayerTimes.size(); i++) {
                        post.append(FacebookIntegration.this.prayerNames[i] + ": "
                                + prayerTimes.elementAt(i));

                    posted = true;
                    // fb.setPermissions(postPermissions);
                    user.publishPost("stream.publish", "published through the Facebook API",
                            APPLICATION_SECRET, null, null, null, user.getId());
                    // try {
                    // fb.refreshAccessToken(true);
                    // } catch (FacebookException e) {
                    // // TODO Auto-generated catch block
                    // e.printStackTrace();
                    // }
                    // fb.logout(true);

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

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

        } finally {


        return true;

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

Re: Facebook integration

HI , 

                 I am facing the same problem not getting the access token , if some one has , some sample code , can u please post it;s very urgent , bec this thing is already taking too much time , please reply as soon Smiley Sad .


Posts: 14
Registered: ‎07-31-2012
My Device: 9790
My Carrier: airtel

Re: Facebook integration

Can you please send the full source code

Regular Contributor
Posts: 52
Registered: ‎07-04-2011
My Device: Bold-3
My Carrier: Developer

Re: Facebook integration


Did you successfully integrate facebook integration in your application ?

I am asking because I have to to the same.

So,if you have done it can you please help me ?