Facebook Improves their Platform Dialogs


FacebookAccording to the facebook developer blog Facebook updated their platform dialogs. So now its become more easy to

– publishing a stream story
– sending a friend request

from your facebook application.  They said “Our new Platform Dialogs are designed to work identically for developers building applications on Facebook.com, third party websites, and mobile devices (both handheld and tablets). You can use a consistent request in your application and we will render a dialog that is optimized for the device and context.

So showing dialog become very easy now. For example feed dialog

http://www.facebook.com/dialog/feed?
  app_id=YOUR_APP_ID&
  link=http://developers.facebook.com/docs/reference/dialogs/&
  picture=http://fbrell.com/f8.jpg&
  name=Facebook%20Dialogs&
  caption=Reference%20Documentation&
  description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&
  message=Facebook%20Dialogs%20are%20so%20easy!&
  redirect_uri=http://www.example.com/response

where data like name, description are url encoded, so using your application id if you direct the user’s browser to above url you’ll see feed dialog. You can use javascript to popup a window and can point this url.

The corresponding graph api example using php is given below. The php code is helpful if you want to auto publish in your friend’s profile or your profile.

if (isset($_REQUEST['publish'])) {
    try {
        $wallpostpage = $facebook->api('/FB_FANPAGEID_OR_YOUR_OR_FRIENDPROFILE_NAME_OR_ID/feed', 'post',
                array(
                'message' => 'I like iThinkdiff.net',
                'description'=> 'Thinkdiff.net contains geeky stuff',
                'picture' => 'http://thinkdiff.net/ithinkdiff.png',
                'caption'=> 'thinkdiff.net caption',
                'link'    => 'http://ithinkdiff.net',
                'name'    => 'iThinkdiff.net',
                'cb'      => ''
                )
        );
    } catch (FacebookApiException $e) {
        print_r($o);
    }
}

For iphone/ipad application using iOS SDK its very easy

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
  kAppId, @"app_id",
  @"http://developers.facebook.com/docs/reference/dialogs/", @"link",
  @"http://fbrell.com/f8.jpg", @"picture",
  @"Facebook Dialogs", @"name",
  @"Reference Documentation", @"caption",
  @"Dialogs provide a simple, consistent interface for apps to interact with users.", @"description",
  @"Facebook Dialogs are so easy!",  @"message",
  nil];

[_facebook dialog:@"feed" andParams:params andDelegate:self];

Facebook Dialog iPhone

For authentication Dialog using oAuth version 2.0 take a look http://developers.facebook.com/docs/reference/dialogs/oauth Now you can easily prompt the user to grant permissions to your application.

From now in your application, users can easily send friend requests to each other. Just use below code

http://www.facebook.com/dialog/friends/?
  id=facebook_user_id_or_username&
  app_id=YOUR_APP_ID&
  redirect_uri=http://www.example.com/response/

If the user clicks “Add Friend”, the browser will redirect to

http://www.example.com/response/?action=1

If the user clicks “Cancel”, the browser will redirect to

http://www.example.com/response/?action=0

So you can easily track to know if a friend request is accepted or not by your application.
References:

  1. Feed Dialog
  2. Friends Dialog
  3. oAuth Dialog
mahmud ahsan

Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

You may also like

1 Comment

  • David
    January 30, 2011 at 4:53 am

    Does anybody have this working so that a feed dialog comes up in a light box in an I frame?

Comments are closed here.

About Me

Hi I am Mahmud Ahsan. I Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

Twitter Feed

Fanpage