Create for the version 6 of module, here the issue for the version 7 http://drupal.org/node/1431826
What I know :
It will be not possible to have request on external website, cause we will obligatory to use the canvas page. So today when you said a request with FBML you have no notification and one link in tab application which is disable (when you clic it append nothing). But if you write the url of canvas in your facebook api (on developpers.facebokk site) you have one notification wich work fine but always a link wich have no effect. I try to make it with the new way, with the js JDK, but I confess that I am bad JS developper. Here the exemple of friend request in new way : http://developers.facebook.com/docs/reference/dialogs/requests/ but "Requests are only available for Desktop Canvas apps and not websites" ....

Comments

musa.thomas’s picture

So i make simething I hope it make in a good way :
Hook menu : one page for the redirection in canvas and one for callback ajax exclude id.

/*
* Implementation of Hook_menu
*/
function module_facebook_menu(){
  // User profile tabs
  $items['fb-invite/accept'] = array(
    'title' => 'accept',
    'page callback' => 'accept_facebook',
    // 'access callback' => 'invite_user_access',
    // 'access arguments' => arrays('accept invitation'),
       'page arguments' => array(1),
    'access arguments' => array('access content'),
    'weight' => 20,
        'type' => MENU_NORMAL_ITEM,
  );
 	$items['fb-invite/exclud_id'] = array(
    		'page callback' => 'exclud_id_facebook',
       'page arguments' => array(1),
        'access arguments' => array('access content'),
    		'type' => MENU_CALLBACK,
  	);
    return $items;
  }
/* Implementation of AJAXPage_callback()
 * Fonction qui renvoi en format json les id facebook à exclure.
 *
*/  
  
function exclud_id_facebook(){
  //Si on est pas sur un appel js
	if (!$_POST['from_js'] && $_GET['example_token'] == drupal_get_token()) 
    {
		return t('Activer le javascript pour pouvoir inviter vos amis.');
		}
	elseif ($_POST['from_js'] && $_POST['example_token'] == drupal_get_token()) 
    {
    global $_fb, $_fb_app;
		$fbu = fb_facebook_user();
		if (!$fbu)
      {
		  drupal_json(t('erreur de connexion Facebook'));
			exit;
			}
		// Exclude users who have already installed.
    $rs = fb_fql_query($_fb, "SELECT uid FROM user WHERE has_added_app=1 and uid IN (SELECT uid2 FROM friend WHERE uid1 = $fbu)"); // FQL not SQL, no {curly_brackets}
		//EMERYA on ajoute la condition qu'il ne soit pas sur le site.
		$res=db_query("SELECT fbu FROM {fb_user} WHERE uid IS NOT NULL AND fbu IS NOT NULL ");  
		$alreadyRegister=array();
		while($result=db_fetch_array($res))
			$alreadyRegister[]=$result['fbu'];  
		$exclude_ids = array();
		 // Build an delimited list of users...
        if ($rs) {
          foreach ($rs as $data) {
		  if(in_array($data["uid"],$alreadyRegister))
            $exclude_ids[] = $data["uid"];
          }
        }
		// $exclude_ids='gg'.$fbu;
    // Set the text/javascript headers and
    // return the response in JSON format.
    drupal_json($exclude_ids);
    exit;
    }
  else 
    {
    drupal_json(t('Page not found'));
    exit;

    }
}
/* Implementation of page_callback()
*
*/
function accept_facebook(){

    //Object facebook et facebook api
    global $_fb, $_fb_app;
    		$fbu = fb_facebook_user();
   //Assuming the user has already authenticated the app
   // $user_id = $facebook->getUser();

   //get the request ids from the query parameter
   $request_ids = explode(',', $_REQUEST['request_ids']);

   //for each request_id, build the full_request_id and delete request  
   foreach ($request_ids as $request_id)
   {
   // $content.= ("request_id=".$request_id."<br>");
      $full_request_id = $request_id . '_' . $fbu;  
   // $content.= ("full_request_id=".$full_request_id."<br>");
  
      // try {
         $delete_success = $_fb->api("/$full_request_id",'DELETE');
      /*   if ($delete_success) {
             $content.= "Successfully deleted " . $full_request_id;}
         else {
             $content.= "Delete failed".$full_request_id;}*/
        // }          
      // catch (FacebookApiException $e) {
     // $content.="error".$e;}
    }
  $content.='<script type="text/javascript">
              top.window.location = \'http://yourForceUrl.com\';
            </script>';
  $content.=t('Vous allez être redirigé dans quelques secondes, merci de patienter.');
        // drupal_goto('http://pastasparty.com#TOP');
  return $content;
}

Here the javascript :

Drupal.behaviors.moduleFacebook = function(context) {
var fbInvite = $('#fb-invite-buton');
	fbInvite.click(function(event) 
    { 
    //Envlève le comportement du bouton car sinon il est lancé plusieurs fois
    fbInvite.unbind('click');
		//bind le comportement ajax du callback de la page
    event.preventDefault();

		// Perform the ajax request - the configurations
		// below can be modified to suit your needs:
		// http://docs.jquery.com/Ajax/jQuery.ajax#options
		$.ajax(
      {
		  type: "POST",
		  url: '/fb-invite/exclud_id',
		  data: {
			'from_js' : true,
			'example_token' : Drupal.settings.exampleToken
		  },
		  dataType: "json",
		  success: function (data)
        {
        // alert_r(data);
        excludeId='';
        if (typeof data!= 'undefined' &&     data.length >0) {
          for(var i=0;i<data.length;i++)
            {
            if(      excludeId!='')
                  excludeId+=',';
                  excludeId+=data[0];
            }
          }
              // alert_r(excludeId);
        // if (data.message) {
          // Remove any messages that are already there. It might
          // be good to abstract this a bit and make a function that
          // can remove the message div. You could then also bind a
          // a link titled "Close" to that function so that the user
          // can acknowledge the message and remove it.
          // $(".messages").remove();

          // The div where your messages div normally shows. This
          // example is from this particular custom theme - change
          // #content-column to the parent selector where your
          // .messages div displays in your theme. If you use the same
          // classes as Drupal, you end up with a nicely styled response
          // right where the user is accustomed to seeing messages.
          // $("#content-column").prepend('<div class="messages status">' + data.message + '</div>');
        // }
      //Construit la fenêtre de dialogue.
      FB.init({
        appId  : Drupal.settings.fb.fb_init_settings.appId
        });
      FB.ui({
        method: 'apprequests',
        message:'Invitation',
        exclude_ids :excludeId
                // data: thisurl
        }, requestCallback);
      },
    error: function (xmlhttp) {
      alert('An error occured: ' + xmlhttp.status);
		  }
		});
		  // alert(Drupal.settings.fb.fb_init_settings.appId);
	});
}

So you can have the dialogue form to call with this link

    $link=l(t('Invitez ses amis (avec personnes excluses)'), 'fb-invite/exclud_id', array(
      'query' => array(
        'example_token' => drupal_get_token()
      ),
      'attributes' => array(
        'id' => 'fb-invite-buton')  
      )
    );

I'm sorry for the comments and some wording in french.
This code need few review like token

Dave Cohen’s picture

Thanks for sharing. Unfortunately I have to confess I don't understand exactly the problem you're trying to solve. I know facebook has deprecated FBML but I'm not sure whether they mean FBML or the newer XFBML. All the XFBML tags still work, as far as I know.

Have you seen the fb_friend.module? It has some helpers for doing invite forms. Like the one that appears on the last page of the drupalforfacebook.org tour: http://apps.facebook.com/drupalforfacebook/node/7/dff_tour/form

It would be easier to consider the change you're suggesting if you made it a patch to that module.

musa.thomas’s picture

I make test with the fb_friend module and it send a request but there some problème after :
-It doesn't make notification on Facebook (if you don't write canvas page in your Facebook application)
-The link wich apear in application have no effect, when you click on it there nothing happen
-I don't know if the Fb_friend module delete the request on facebook.api as facebool recommended "It is the Developers' responsibility to delete a Request once it has been accepted. For more information on how to delete a Request, please see the Deleting Requests documentation."
-Sometimes unlimited javascript load(don't load)

I will clean up the code if have got times (cause many work now)

* I report it on developper facebook, and they say" ok thank for report just FBML is depreciated." and close ticket with status "won't fix"

musa.thomas’s picture

Just one question, have you fill in the https canvas url? cause for me not and when you click on link of invitation send (in facebook) it write that this url is not secure.
Try to clean the code tonight

Dave Cohen’s picture

The latest, rc.5 or .dev, will try to provide secure callbacks. its worth an upgrade.

musa.thomas’s picture

mmmm I'm not sure to understand your last answer but for me it was a question for https for canvas page wich are obligatory on Facebook (cause with the new request dialog canvas page are obligatory). But I find the solution, the cloud services : http://devcenter.heroku.com/articles/facebook after to hav'nt the canvas page i force the redirection on it to my siteweb.
Have you try your request? I mean the request with fb_friend module? I try on your site and I can confirm that the links wich appear on Facebook have no effect, when you click nothing happen.

Dave Cohen’s picture

Title: FBML has been deprecated since 1/1/2012 » fb_friend.module invitations delivered, but do not work
Version: 6.x-3.2-rc3 » 6.x-3.x-dev
Component: Canvas Pages (FBML, deprecated) » Code
Category: feature » bug
Priority: Critical » Normal

There is an issue with the invitations. Something about the API has changed, I don't know exactly what, but I confirm that invites from drupalforfacebook.org are being delivered, but not working properly.

I'll look at your code in more detail when I have a moment...

mayur.pimple’s picture

Hi

Invite friends is working fine on following tutorial.

checkout this links.
http://thinkdiff.net/facebook/php-sdk-3-0-graph-api-base-facebook-connec....

I have done on my custom module. this weekend i will try send code.

if you have urgency then contact me: mayurpimple12@gmail.com