0

i am making a facebook application, everything seems done. here is the sample flow(index.php):

  1. seekpermission.php

  2. processinfo.php

  3. generateresult.php

  4. poststatus.php(the javascript way as told in the documentation)

  5. invitefriends.php(the javascript way as told in the documentation)

hope the names are self explanatory. the trouble is the dialogue to update status and invite friends comes almost parallely, but what i want is once the user publishes/skips the status message only then should the dialogue of invite friends should come. here is what i tried but it is not working, please help thanks!

 FB.ui(
    {
        method: 'feed',
        name: 'name goes here',
        link: 'http://apps.facebook.com/****/',
        picture: '<?php echo $imageurl; ?>',
        caption: 'here is caption',
        description: 'the description',
        message: '<?php echo $charecter; ?>'
    },
    function(response) {
    if (response && response.post_id) {
    alert('<?php include "invitefriends.php"; ?>');

    } else {

    alert('<?php include "invitefriends.php"; ?>');

 }

here is the invitefriends.php

<body>
   <div id="fb-root"></div>
   <script src="http://connect.facebook.net/en_US/all.js">
   </script>
   <script>
     FB.init({ 
       appId:'2****', cookie:true, 
       status:true, xfbml:true 
     });

     FB.ui({ method: 'apprequests', 
       message: 'Folks check out my new facebook app!! visit http://apps.facebook.com/**** '});
   </script>
   </body>
Ram Kumar
  • 590
  • 2
  • 10
  • 27
  • This should work. I have used this before. Maybe the problem is with how the code looks after the php files are imported. Can you maybe post the content of the php file. – Elad Lachmi Mar 20 '11 at 06:44

1 Answers1

0

Well, that's a weird way to accomplish a simple task:
You can combine step 4 & 5 in one step:

FB.ui(
    {
        method: 'feed',
        name: 'name goes here',
        link: 'http://apps.facebook.com/****/',
        picture: '<?php echo $imageurl; ?>',
        caption: 'here is caption',
        description: 'the description',
        message: '<?php echo $charecter; ?>'
    },
    function(response) {
        FB.ui({ method: 'apprequests', 
        message: 'Folks check out my new facebook app!! visit http://apps.facebook.com/**** '});
        /* if (response && response.post_id) {
            alert('<?php include "invitefriends.php"; ?>');

        } else {

            alert('<?php include "invitefriends.php"; ?>');

        } */
    }
)

As you can see no need for the if else since you will force the invite anyway!

Now if you really need to use your approach, then you may use something like (in the response:

location.href='<?php echo 'path/to/invitefriends.php';

IMPORTANT NOTE:
Most likely ALL your 5 steps can be combined in ONE file, this is better because:

  1. You don't need to load and initialize the JS-library FIVE times!
  2. Will be a better user experience instead of loading each time
  3. You can wrap all the Facebook Calls in JS functions and just call each one in the response of the previous one!
ifaour
  • 38,035
  • 12
  • 72
  • 79
  • thnx i faour for the reply i implemented it an it does work, but again i get stuck, this time because if pop-up is blocked in browser the status update pop up dialogue does not work. do you have any work around for it. please help, its the last step! – Ram Kumar Mar 21 '11 at 21:40
  • @RahulSharma: is `FB.ui` considered a "pop-up" in first place?! I would suggest you ask another questions with screenshots if possible. – ifaour Mar 21 '11 at 22:19
  • here you go : http://stackoverflow.com/questions/5387381/facebook-application-dialogue-to-publish-on-users-wall-using-javascript-api-p – Ram Kumar Mar 22 '11 at 19:03
  • ifaour im still stuck and waiting for your answer – Ram Kumar Mar 23 '11 at 13:08