简体   繁体   中英

Facebook apprequest not being sent to facebook users

I'm developing a web app integrated with facebook and I'm using the request dialog to invite new users. So a user of my app can click on a button to send an apprequest to some of his facebook friends which are not users yet.

exports = fm.namespace(this,'bla','facebook')

exports['init'] = function(){
  window.fbAsyncInit = function() {
    if (undefined !=RAILS_ENV['facebook_app_id'])
    {FB.init({
               appId      : RAILS_ENV['facebook_app_id'], // App ID
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      oauth      : true, // enable OAuth 2.0
      xfbml      : true  // parse XFBML
             });}
  };

  // Load the SDK Asynchronously
  (function(d){
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
  }(document));
}
exports['sendRequestToOneRecipient']= function (uid) {
  FB.ui({method: 'apprequests',
    message: "bla bla",
    to: uid 
  }, requestCallback);

  function requestCallback(response) {
    if (response && response.to) {
      console.log("Message was sended"); 
    } else {
      console.log("Message was not sended.");
    }
  }
}

As far as I know it does not requiere any permissions because is a explicit action from the user. When a user clicks the button, the facebook window appears and everything is working fine. The callback is sending back the appId and the userid of the destinatary but the message is never being notifified in facebook destinatary account

No javascript errors on the console

Similary I'm posting to the wall of facebook friends and it is working without any issues. The same code but instead of 'apprequest', the method is 'feed'

To solve the problem I've just marked my app as facebook application and added a canvas secure url, so when the user receives my apprequest it could be redirected to a valid site. As soon as I added that url, the users receive all the notifications.

The problem now, is that I have to create a specfic page to embeed as an iframe, because my website doesn't look proper as an iframe. Also I have to adquire a ssl certificate because canvas url must be https. If anyone knows a workaround, please let me know.

Thanks for your anwsers

Put the following in your template file:

if (top.location != self.location)
{
    top.location = self.location
}

If the location of the main website you're on isn't the same as your website's location it redirects you to your website.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM