Cannot access friends information.

58 views
Skip to first unread message

Joachim Petersen

unread,
May 8, 2013, 5:00:09 AM5/8/13
to facebook-act...@googlegroups.com
Hello I am using this code:

           function onFriendsListLoaded(response){
            //alert("divTarget="+divTarget+"\ndata="+data);
                for (var friendIndex=0; friendIndex<data.length; friendIndex++){
                    //divContainer.innerHTML="<hr><img src='http://graph.facebook.com/"+data[friendIndex].id+"/picture'></img>"+
                    //"<br>"+data[friendIndex].name;
                    //divTarget.appendChild(divContainer);
                    trace(data[friendIndex].name)
                }
            }
           
            function showFriendsList(){
                FacebookMobile.api('/me/friends', onFriendsListLoaded);
            }

I am getting this error:
onFriendsListLoaded(). Expected 1, got 2.

Anyone know why that code is not working?

Khaled Garbaya

unread,
May 8, 2013, 5:03:35 AM5/8/13
to facebook-act...@googlegroups.com
every api callback must accept two paramaters response and fault

so you'll function definition should be : 
 function onFriendsListLoaded(response, fault){
.....
}
response hold the returned data if the request is seccessfull and fault will be null
if the request not sucessfull the fault will contain the error message etc... and responce will be null



2013/5/8 Joachim Petersen <joachim...@live.com>

--
You received this message because you are subscribed to the Google Groups "facebook-actionscript-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to facebook-actionscr...@googlegroups.com.
To post to this group, send email to facebook-act...@googlegroups.com.
Visit this group at http://groups.google.com/group/facebook-actionscript-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Cordialement,
Khaled Garbaya
Senior Flash Developer & chef d'equipe flasheurs
StreamerZ
----------------------------------------------
17, rue du Liberia
Tunis – Tunisie
Tel : (+216) 71 28 00 19 
Fax : (+216) 71 28 00 33 
www.streamerz.net

Khaled Garbaya

unread,
May 8, 2013, 5:04:31 AM5/8/13
to facebook-act...@googlegroups.com
 function onFriendsListLoaded(response:Object, fault:Object){
.....
}


2013/5/8 Khaled Garbaya <kha...@streamerz.net>

Joachim Petersen

unread,
May 8, 2013, 5:07:47 AM5/8/13
to facebook-act...@googlegroups.com
function onFriendsListLoaded(success, fail){
                if (success){

                    for (var friendIndex=0; friendIndex<data.length; friendIndex++){
                        //divContainer.innerHTML="<hr><img src='http://graph.facebook.com/"+data[friendIndex].id+"/picture'></img>"+
                        //"<br>"+data[friendIndex].name;
                        //divTarget.appendChild(divContainer);
                        trace(data[friendIndex].name)
                    }
                }
            }

now it return null error:

Joachim Petersen

unread,
May 8, 2013, 5:08:18 AM5/8/13
to facebook-act...@googlegroups.com
Error:
Cannot access a property or method of a null object reference.

Khaled Garbaya

unread,
May 8, 2013, 5:10:39 AM5/8/13
to facebook-act...@googlegroups.com
in you your trace(data[friendIndex].name) it should be trace(success[friendIndex].name)


2013/5/8 Joachim Petersen <joachim...@live.com>
Error:
Cannot access a property or method of a null object reference.

--
You received this message because you are subscribed to the Google Groups "facebook-actionscript-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to facebook-actionscr...@googlegroups.com.
To post to this group, send email to facebook-act...@googlegroups.com.
Visit this group at http://groups.google.com/group/facebook-actionscript-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joachim Petersen

unread,
May 8, 2013, 5:15:51 AM5/8/13
to facebook-act...@googlegroups.com
It is this line that triggers the error:

for (var friendIndex=0; friendIndex<data.length; friendIndex++){

Khaled Garbaya

unread,
May 8, 2013, 5:16:43 AM5/8/13
to facebook-act...@googlegroups.com
Ye because data does not existe in your code


2013/5/8 Joachim Petersen <joachim...@live.com>
--
You received this message because you are subscribed to the Google Groups "facebook-actionscript-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to facebook-actionscr...@googlegroups.com.
To post to this group, send email to facebook-act...@googlegroups.com.
Visit this group at http://groups.google.com/group/facebook-actionscript-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joachim Petersen

unread,
May 8, 2013, 5:17:17 AM5/8/13
to facebook-act...@googlegroups.com
Sorry you were right the first time, forgot to change the data to success in that line, do'h.

Thank you, your a real hero on here!
Reply all
Reply to author
Forward
0 new messages