BlackBerry - Facebook extended permissions

Posted by Max Gontar on Stack Overflow See other posts from Stack Overflow or by Max Gontar
Published on 2010-03-31T13:12:39Z Indexed on 2010/03/31 13:13 UTC
Read the original article Hit count: 601

Hi!

I've just found a great sample of Facebook Connect on Blackberry by Eki Y. Baskoro,

The following is a short HOWTO on using Facebook Connect on Blackberry. I created a simple Facade encapsulating the Facebook REST API as well as added 'rough' MVC approach for screen navigation. I have tested on JDE 4.5 using 8320 simulator. This is still work in progress and all work is GPLed.

It works great for reading stuff.

NB Don't forget to get Facebook App Key and set it in TestBB class.

But now I want to post something on my wall. So I've add new method to FacebookFacade class using Stream.publish API:

 /***
 * Publishes message to the stream.
 * @param message - message that will appear on the facebook stream
 * @param targetId - The ID of the user, Page, group, or event where 
 *     you are publishing the content.
 */
public void streamPublish(String message, String targetId)
{
    Hashtable arguments = new Hashtable();
    arguments.put("method", "stream.publish");
    arguments.put("message", message);
    arguments.put("target_id", targetId);
    try {
        JSONObject result = new JSONObject(
        int new JSONTokener(sendRequest(arguments)));            
        int errorCode = result.getInt("error_code");
        if (errorCode != 0) System.out.println("Error Code: "+errorCode);
    } catch (Exception e) {
        System.out.println(e);
    }
}

 /***
 * Publishes message on current user wall.
 * @param message - message that will appear on the facebook stream
 */
public void postOnTheWall(String message)
{
    String targetId = String.valueOf(getLoggedInUserId()); 
    streamPublish(message, targetId);
}

This will return Error code 200, "The user hasn't authorized the application to perform this action"

First I thought it's related with Facebook -> Application Settings -> Additional Permissions -> Publish recent activity (one line stories) to my wall but even checked, no difference...

Then I've found this post explains that issue related with extended permissions.

This in turn should be fixed by modifying url a little in LoginScreen class :

public LoginScreen(FacebookFacade facebookFacade) {
    this.facebookFacade = facebookFacade;

    StringBuffer data = new StringBuffer();
    data.append("api_key=" + facebookFacade.getApplicationKey());
    data.append("&connect_display=popup");
    data.append("&v=1.0");
    //revomed
    //data.append("&next=http://www.facebook.com/connect/login_success.html");
    //added     
    data.append("&next=http://www.facebook.com/connect/prompt_permissions.php?" +
    "api_key="+facebookFacade.getApplicationKey()+"&display=popup&v=1.0"+
    "&next=http://www.facebook.com/connect/login_success.html?"+
    "xxRESULTTOKENxx&fbconnect=true" +
    "&ext_perm=read_stream,publish_stream,offline_access");     
data.append("&cancel_url=http://www.facebook.com/connect/login_failure.html");
    data.append("&fbconnect=true");
    data.append("&return_session=true");
    (new FetchThread("http://m.facebook.com/login.php?" 
            + data.toString())).start();
}

Unfortunately it's not working. Still Error Code 200 in return to stream.publish request...

Do you have any suggestions how to resolve this?

Thank you!

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about rest