开发者

BlackBerry - Facebook extended permissions

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);
    argum开发者_JAVA技巧ents.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!


I have posted the updated API on my website (http://www.baskoro.web.id/facebook-connect-blackberry-HOWTO.html) and this should solve this issue. Please let me know otherwise.

Salam. Cheers!

Eki

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜