Change facebook.showFeedDialog to facebook.streamPublish


facebookFacebook announced in their road-map about some major changes in the late 2009. Some of those changes now activated in facebook.  One of these important changes is to deprecate feed publish and replace it with stream publish.

I support it and like it. Because stream publishing is much easier and simple than feed publishing. This is a technical issue. So if you didn’t already change your feed publishing method to stream publish method, then you should do the change right now. Otherwise the wall post publish box will not work in your facebook or facebook connect application at anytime.

 "description": 'I just found an idiot friend today! The idiot friend is <?=$idiotName?>. Oh really! LOL .',

I’m now providing a simple example that will help you to update your code. For this wall post dialog I wrote a javascript function that used facebook.showFeedDialog() javascript api method. This was a working code where php variable are rendered with actual values.

function showWallDialog(){
	    var data    =   {
            "appLink"    : 'http://apps.facebook.com/idiot-of-the-day',
            "appTitle"   : 'Idiot of the day',
            'idiot'    : "<?=$idiotName?>",
            "images":[  <?php $flag = false; ?>
                    <?php foreach($idiotPhotos as $photo) { ?>
                        <?php if ($flag) echo ','; $flag = true; ?>{
                         'src': '<?=$photo?>',
                         'href': '<?=getAppLink()?>'
                        }
                    <?php } ?>]
            };

            Facebook.showFeedDialog("<?=$config['feed_idiot']?>", data,'','', '');
}

Now I changed my function to follow facebook new method:

function showWallDialog(){
        var message = "";
        var actionLinks = [{ "text": "Find your Idiot Friend!", "href": "<?=$config['app_base_url']?>"}];

        var attachment    =   {
              "description": 'I just found an idiot friend today! The idiot friend is <?=$idiotName?>. Oh really! LOL.',
             "media":[  <?php $flag = false; ?>
                <?php foreach($idiotPhotos as $photo) { ?>
                <?php if ($flag) echo ',';
                     $flag = true; ?>{
                        'type': 'image',
                        'src': '<?=$photo?>',
                        'href': '<?=getAppLink()?>'
                }
                <?php } ?>]
        };

        Facebook.streamPublish(message, attachment, actionLinks, '', '', '');
}

So you shouldn’t delay to update facebook new api. For FB Connection base application please use FB.Connect.streamPublish() method.

For more information please visit:

1. http://wiki.developers.facebook.com/index.php/Facebook.showFeedDialog (Deprecated soon)
2. http://wiki.developers.facebook.com/index.php/Facebook.streamPublish

Facebook announced in their road-map about some major changes in the late 2009. Some of those changes now activated in facebook.  One of these important changes is to deprecate feed publish and replace it with stream publish.
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

15 Comments

  • Noirita
    May 27, 2010 at 5:55 pm

    Urgent requirement –

    This function is meant to publish a pop up to ask user permission to post to wall after they completed filling a form. Now if the user clicks on the his friend app tab after skipping/sharing wall post feed form, the pop up shows again without even being called!!!

    Do you have any solution for it ?

    Thanks in advance

  • mahmud ahsan
    mahmud ahsan
    May 27, 2010 at 11:58 pm

    I don’t agree without call the function facebook will show the popup screen. Because right now i’m working using it and i don’t find any problem for my app. Please check the code again.

  • Noirita
    May 28, 2010 at 9:04 pm

    http://bugs.developers.facebook.com/show_bug.cgi?id=7685
    please check out above link.

  • Juan
    July 13, 2010 at 12:57 am

    mahmud,
    how did you work php variables in js?

    regards

    • mahmud ahsan
      mahmud ahsan
      July 13, 2010 at 11:52 pm

      Because I parse js code in php file that’s why php variable is replaced with actual value in js. You can easily put html/css/javascript code in php file without php tags. For example,

      index.php is a php file here i can put javascript file

      <script type="text/javascript">
      var myname = "<?=$name?>";
      </script>
      <?php
      //some php code
      ?> 
      
      • dev
        January 21, 2012 at 10:29 am

        dgfgfg

  • Juan
    July 20, 2010 at 7:28 pm

    Mahmud,
    Thanks, many thanks for your help.

  • Marisol P.
    October 20, 2010 at 3:30 am

    Hi Mahmud,

    How did you call the “function showWallDialog()” in php
    in the way that you did in your app “Idiot of the day”
    shown as an intruder in the very first time.

    Thanks
    Marisol

    • mahmud ahsan
      mahmud ahsan
      October 21, 2010 at 12:44 am

      I think that code is deprecated and will not work soon.

  • Reinier
    January 23, 2011 at 12:15 pm

    Hi,

    Do you have any idea how to call this from PHP? I have a form in my app that I need to validate with PHP. If it validates I want to show the dialog with some pre-set fields.

    The problem is I need to call this from Javascript and there seems to be no way to call it directly from PHP. The Graph API seems to only support a direct post (with no dialog), but that’s not what I want.

    Thanks in advance!

    • mahmud ahsan
      mahmud ahsan
      January 23, 2011 at 6:20 pm

      I think you could just load the javascript sdk and use the javascript api.

  • Reinier
    January 23, 2011 at 7:01 pm

    Thanks for the reply, but that’s not what I meant.
    I need the PHP validation (JS validation is client-side). After my function returns no errors, I need to call the dialog.
    Something like:
    if (i!sset($errors)) {
    postMessage(); //function that calls the dialog
    }

    With the JS SDK I can call FB.UI(), but you can’t call a JS function from PHP.

  • Reinier
    January 23, 2011 at 8:06 pm

    Okay, I can redirect the browser with a header, but it keeps showing me a Facebook logo that the user has to click, instead of immediately the popup:
    header(‘Location: http://www.facebook.com/dialog/feed?app_id=xxxxxxxxxxxxxxx&message=hello&redirect_uri=http://www.x-plicit4.nl/facebook/‘, true);

  • ritchi3
    February 6, 2012 at 3:44 pm

    Can I set the image size?

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