Hello,

First of all - great module. Made my life so much easier. I've created a facebook application using this - it's at http://apps.facebook.com/healthandhappiness/

I used the invite page feature - and when users invite their friends - the friends receive the invitation but when they actually try to add the application - it just returns to the facebook home page without adding the application.

I noticed the same behavior when you using the sample page http://apps.facebook.com/drupalforfacebook/fb/invite

Am I missing something - do I have to do something in my application to make the inviate page work?

Comments

sushilmasti’s picture

found the problem - the api_key was not being sent due to a bug/incomplete code in fb_form.module instead the app id was being sent in the parameter api_key....

incorrect code


  if ($fb_app->id) {
    $content .= "<fb:req-choice url=\"http://www.facebook.com/add.php?api_key={$fb_app->id}&next={$sNextUrl}\" label=\"" . t('Add !title application.',
                                                                                                                             array('!title' => $fb_app->title)) . " />";
  }

correct_code


  if ($fb_app->id) {
    $content .= "<fb:req-choice url=\"http://www.facebook.com/add.php?api_key={$fb_app->api_key}&next={$sNextUrl}\" label=\"" . t('Add !title application.',
                                                                                                                             array('!title' => $fb_app->title)) . " />";
  }

I'm still not sure what the sNextUrl is for - there seems to be missing code in the module referring to uninitialized variable $user specifically
// Construct a next url for referrals
$sNextUrl = urlencode("&refuid=".$user);
}

Dave Cohen’s picture

Component: Miscellaneous » Code
Assigned: Unassigned » Dave Cohen
Category: support » bug
Status: Active » Needs review

Whoa, nice catch. That was sloppy of me. I copied much of that code from an example on the facebook api wiki. I thought it was working, but obviously did not test much.

I'm not on my normal machine, so I'm having trouble generating a proper patch file, but here's the change I intend to check in to fix this. I'm doing away with the sNextUrl business at least for now.

Index: fb_form.module                                                           
===================================================================
--- fb_form.module  (revision 1291)                                             
+++ fb_form.module  (working copy)                                              
@@ -33,9 +33,9 @@
  */                                                                            
 function fb_form_form_alter($form_id, &$form) {                                
   // Drupal allows no clean way to set $form['#type'], so we hack...           
-  if ($type = $form['#type_hack']) {                                           
+  if ($type = $form['#fb_form_type_hack']) {                                   
     $form['#type'] = $type;                                                    
-    unset($form['#type_hack']);                                                
+    unset($form['#fb_form_type_hack']);                                        
   }                                                                            
 }                                                                              
                                                                                
@@ -93,9 +93,6 @@
         $arFriends .= $rs[$i]["uid"];                                          
       }                                                                        
     }                                                                          
-                                                                               
-    //  Construct a next url for referrals                                     
-    $sNextUrl = urlencode("&refuid=".$user);                                   
   }                                                                            
                                                                                
   // Use node body in invite message.                                          
@@ -103,13 +100,13 @@
   $node = node_prepare($node);                                                 
   $content = $node->teaser;                                                    
                                                                                
-  if ($fb_app->id) {                                                           
-    $content .= "<fb:req-choice url=\"http://www.facebook.com/add.php?api_key=\
{$fb_app->id}&next={$sNextUrl}\" label=\"" . t('Add !title application.',       
-                                                                              \
                                               array('!title' => $fb_app->title\
)) . " />";                                                                     
+  // Do we need to append &next=[someURL] to the url here?                     
+  $content .= "<fb:req-choice url=\"http://www.facebook.com/add.php?api_key={$\
fb_app->api_key}\" label=\"" . t('Add !title application.',                     
+                                                                              \
                                 array('!title' => $fb_app->title)) . " />";    
   }                                                                            
                                                                                
   // form type fb:request-form                                                 
-  $form = array('#type_hack' => 'fb_form_request', // becomes #type during for\
m_alter                                                                         
+  $form = array('#fb_form_type_hack' => 'fb_form_request', // becomes #type du\
ring form_alter                                                                 
                 '#attributes' =>                                               
                 array('type' => $fb_app->title,                                
                       'content' => htmlentities($content),                     





Dave Cohen’s picture

Status: Needs review » Fixed

This didn't receive as much testing as I'd like, but I checked it in anyway.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.