daogr / facebook-actionscript-api

Automatically exported from code.google.com/p/facebook-actionscript-api
0 stars 0 forks source link

Facebook.ui with 'apprequests' method does not invoke callback function with 'cancel button' #279

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Invoke following code:

Facebook.ui("apprequests",
   {message: 'Hey there!', filters: ['app_non_users'],          data: 'tracking', title: 'Invite your friend.'},
                callback
            );

public function callback( response : Object ) : void 
{
     Alert.show("ok");
}

2. Application shows invite friend dialog
3. User press 'Cancel button'.
4. No alert dialog. 

What is the expected output? What do you see instead?
- The callback function should be invoked at least, and return a null object, 
make the alert dialog popped up. But nothing happen.

What version of the product are you using? On what operating system?
- Chrome 10
- FireFox 3.6
- Internet Explorer 7,8,9
OS
- Windows 7 
- Max OS X Snow leopard

NOTE: The 'response' object will be put into 'callback' function, if user 
invites some friend and press 'invite' button.

Original issue reported on code.google.com by teera...@gmail.com on 27 Mar 2011 at 5:58

GoogleCodeExporter commented 8 years ago
Try adding a fail:Object param to your callback. Like this:

public function callback(response:Object, fail:Object):void

Original comment by rovertn...@gmail.com on 31 Mar 2011 at 3:33

GoogleCodeExporter commented 8 years ago
Thank you, I already tried your solution. But the callback still doesn't 
invoked if user press 'cancel' button. 

I was surprised that user invited at least 1 friend, and then press 'invite' 
button will trigger the callback.

Original comment by teera...@gmail.com on 1 Apr 2011 at 3:51

GoogleCodeExporter commented 8 years ago
I don't sure is this the bug from Facebook JS SDK. I tried FB.ui in Facebook JS 
console, with 'apprequests', the console seems not trigger callback if user 
press 'cancel' too.

Original comment by teera...@gmail.com on 1 Apr 2011 at 4:06

GoogleCodeExporter commented 8 years ago
Yea, the api relies on the javascript sdk to fire the callback. It may be a bug 
on the JS sdk end if that doesn't happen on user cancel. Is this issue still 
happening?

Original comment by edwar...@gmail.com on 25 Oct 2011 at 8:18

GoogleCodeExporter commented 8 years ago
Has anyone found a solution to this issue. I've spent 3 days researching it, 
and see similar issues, but no fix. All I am trying to do is determine if 
someone sent a request to a friend, or canceled. 

I am using Actionscript 3 with the new GraphAPI version 1.8, and also the 
latest version of GraphAPI for PHP, including the link to the javascript file.  
I get an error in both Chrome and IE when I cancel or send a request. 

The error is:
Uncaught Error: Error calling method on NPObject
Uncaught Error: Error calling method on NPObject.
cb
(anonymous function)all.js:22
FB.provide._xdRecvall.js:22
(anonymous function)all.js:22
FB.provide.recvall.js:12
FB.provide.PostMessage.onMessage

I've tried just about everything to get this simple function to work, but no 
luck.

I am loading this script file: src="http://connect.facebook.net/en_US/all.js"

My parameters for swfobject.embedSWF is set to :params.allowScriptAccess = 
"always"

In my Actionscript 3 I am using the following:

import com.facebook.graph.Facebook;
import com.facebook.graph.data.FacebookSession;
import com.facebook.graph.net.FacebookRequest;
import flash.system.Security;

       Security.allowDomain("*.facebook.com");
       Security.allowDomain("*.localdomain.net");
       Security.allowDomain("graph.facebook.com");
        Security.allowDomain("profile.ak.fbcdn.net");
        Security.allowDomain("static.ak.fbcdn.net");
      // Security.allowDomain("*"); //Tried this as well
        Security.allowInsecureDomain("*");

Security.loadPolicyFile("http://graph.facebook.com/crossdomain.xml");
        Security.loadPolicyFile("http://profile.ak.fbcdn.net/crossdomain.xml");

function inviteFriends():void
{
   var dat:Object = new Object();
    dat.message = "Please check out this Game! I'll be waiting for you. Thanks, "+fname;
    dat.title   = 'Game';

  Facebook.ui('apprequests', dat, onUICallback, 'iframe');
    ExternalInterface.call("hidegame",'');// use this to hide game for older browser versions. This works fine.

}

function onUICallback(result:Object):void{

    if(result == null){
        trace('User closed the pop up window without inviting any friends');
         return
    }
    var invitedUsers:Array  = new Array();
    invitedUsers = result.request_ids as Array;
    trace('You Have Invited ', invitedUsers.length,' friends');
    //Simple if else if you want user to invite certain amount of friends
    if(invitedUsers.length > 1){
        trace('GREAT, USER IS GENERATING TRAFFIC');
    }else{
        trace('No Good, User invited only one friend.');
    }

    ExternalInterface.call("showgame",'');//show game for older browsers.
}

The callback does not seem to work. I removed all code, and just had the 
showgame script, which works with a link.

The error seems to suggest that something in the all.js script is unable to 
pass the information back to Flash.

Can someone help with this issue? Everything else works perfectly. I can access 
user date, post to the wall, access pictures, and there are no other problems, 
just can't seem to get the CallBack function to work.

I am desperate to get this fixed so I can move on.

I need to use the CallBack function for multiple reasons, including enabling 
the game for older browsers, due to the iframe showing up behind the game, 
which the popup function doesn't work due to popup blockers, and I don't want 
to use the wmode=transparent because I have actionscript functions using the 
scroll and mouse functions.

I appreciate any help on this and will continue to look around.

I also tried the fail:object in the callback, but that doesn't work either.

The callback just doesn't work with any browser version. The iframe comes up, I 
can select friends, and send request, but it never performs the callback.

Thanks,
Dave

Original comment by CraZyDav...@gmail.com on 1 Dec 2011 at 11:43

GoogleCodeExporter commented 8 years ago
I just tried the channelURL in the fb.int under Actionscript3 and Javascript, 
but this did not fix the problem. 

 FB.init({
          appId   : '<?php echo $facebook->getAppId(); ?>',
         /* session : <?php echo json_encode($session); ?>,*/ // don't refetch the session when PHP already has it
          status  : true, // check login status
          cookie  : true, // enable cookies to allow the server to access the session
          xfbml   : true, // parse XFBML
          channelUrl : 'http://www.domain.net/folder/channel.html'
        });

Actionscript3

Facebook.init('appid',FBConnected,{perms:"read_stream,publish_stream,email",chan
nelUrl:'http://www.domain.net/folder/channel.html'}); 

What is going on???

Original comment by CraZyDav...@gmail.com on 2 Dec 2011 at 12:30

GoogleCodeExporter commented 8 years ago
Alright, after days and hours of testing, I now have this working. It had to do 
with the DIV with dispay=none. If a flash swf is within a hidden div, the call 
back function does not work. Also I moved my code in actionscript 3 to the very 
bottom of the page, and ended up moving the div off the page instead of hiding 
it, so when the call back function is made, the div is moved back on the page.

This was to fix an issue with IE 8 and below. I'm using the iframe instead of 
popup on the apprequest function, and the iframe was getting stuck behind the 
game. So now instead of hiding the div, I move it. I can't set wmode to 
transparent because the scroll doesn't work, and the javescript scroll function 
was messy. I tried to change the wmode dynamically which worked, but always 
reloaded the game. What a pain.

Here is some code in the event someone else is trying to do something similar.
I only wanted to hide the game in IE 8 or below, because it works in Chrome, 
Firefox, and IE 9, so I didn't want to hide the game for these browser versions.

ActionScript 3:

function inviteFriends():void
{
   var dat:Object = new Object();
    dat.message = "Please check out this Game! I'll be waiting for you. Thanks, "+fname;
    dat.title   = 'Game';
    // filtering for non app users only
    //dat.filters = ['app_non_users'];
    //You can use these two options for diasplaying friends invitation window 'iframe' 'popup'
  // Security.allowDomain("apps.facebook.com"); 
  // ExternalInterface.addCallback();
  Facebook.ui('apprequests', dat, onFriendback, 'iframe');
    ExternalInterface.call("hidegame",'');

}

function onFriendback(result:Object):void{

    ExternalInterface.call("showgame",'');

}

Javascript:

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var fullVersion  = ''+parseFloat(navigator.appVersion); 
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;

if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 browserName = "IE";
 fullVersion = nAgt.substring(verOffset+5);
}

function hidegame(what){

if(browserName=='IE' && majorVersion<9){

document.getElementById('div').style.position="absolute";//div containing game
document.getElementById('div').style.left="-9999px";
}
}

function showgame(what){
if(browserName=='IE' && majorVersion<9){
document.getElementById('div').style.position="relative";//div containing game
document.getElementById('div').style.left="0";

}

}

<div id="div">

>script type="text/javascript"<
            //Dynamic publishing with swfObject 
            var flashvars = {};
            //flashvars.xml_file = "pano1.xml";
            var params = {};
            params.allowfullscreen = "true";
            params.allowScriptAccess = "always";
            //params.wmode = "Window";
            //A 'name' attribute with the same value as the 'id' is REQUIRED for Chrome/Mozilla browsers
            var attributes = {};
    attributes.id= "FBGame";
    attributes.name= "FBGame";

            swfobject.embedSWF("<?php echo $fsw; ?>?<? echo(time()) ?>", "flashContent","100%", "615", "10.0.0", null, null, params,attributes);    //, {name:"flashContent"}       //615

        >/script<

</div>

Well that is all folks, onto other fun problems. Enjoy your nights..

Thanks,
Dave

Original comment by CraZyDav...@gmail.com on 2 Dec 2011 at 4:55

GoogleCodeExporter commented 8 years ago
I'm having the same issue, but even worse is that I only get a callback if the 
user accepts if I'm using internet explorer. I've tried using Facebook.api 
instead of Facebook.ui and I have the exact same issues, so the problem doesnt' 
seemed to be at all tied to the js sdk. Anybody have any ideas why this issue 
would be tied to chrome/firefox?

Original comment by MrCreat...@gmail.com on 7 Dec 2011 at 9:23

GoogleCodeExporter commented 8 years ago
I'm having the same issue, but even worse is that I only get a callback if the 
user accepts if I'm using internet explorer. I've tried using Facebook.api 
instead of Facebook.ui and I have the exact same issues, so the problem doesnt' 
seemed to be at all tied to the js sdk. Anybody have any ideas why this issue 
would be tied to chrome/firefox?

Original comment by MrCreat...@gmail.com on 7 Dec 2011 at 9:23

GoogleCodeExporter commented 8 years ago
Try add your callback function as the following:

if (ExternalInterface.available) { 
ExternalInterface.addCallback("uiResponse",uiResponse)};

Original comment by todayra...@gmail.com on 27 Jul 2012 at 11:17

GoogleCodeExporter commented 8 years ago
Here's a simple solution that works for me in Flash I have this code:

var dataObj:Object = {
    method:'apprequests',
    title: "Window title", 
    message:  "Here's some message", 
    filters: ["app_non_users"], 
    data: "friendUID=[insertYourFacebookUIDHere]",
    oauth:true, 
    frictionlessRequests:true,
    to: "[insertFriendFacebookUID],[insertFriendFacebookUID]"
};

ExternalInterface.addCallback("sendGiftCallback", sendGiftCallback);
ExternalInterface.call("sendAppRequests", dataObj);

...and here's the callback:
private function sendGiftCallback(success:Object=null, fail:Object=null):void {
    trace("sendGiftCallback success:"+success+" fail:"+fail);
}

Then in your page containing the swf I have this javascript function:
function sendAppRequests(obj) {
    FB.ui(obj, function(response) {
        onSendRequest(response);
    });
}
function onSendRequest(result) {
    getFlashObj().sendGiftCallback(result);
}

function getFlashObj() {
    var flashObj;
    if (navigator.appName.indexOf("Microsoft") != -1) {
        flashObj = window["flashContent"];
    } else {
        flashObj = document["flashContent"];
    }
    return flashObj;
}

Your swf needs to be in a div called 'flashContent'

Original comment by r...@crispybyte.com on 30 Oct 2012 at 12:32