Okay, I used some javascript to retrieve the friendlist from facebook, iterate over them and add a list field (dual column) and call it via a button
(I already have the FB.init etc loaded..)
<script type="text/javascript">
function getFriends(){
oFormObject = document.forms['gform_5'];
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me/friends', function(response) {
if(response.data) {
var num = 0;
jQuery.each(response.data,function(index,friend) {
console.log(num+'-'+friend.name);
gformAddListItem(oFormObject.elements["input_8[]"][num], 0);
oFormObject.elements["input_8[]"][num].value = friend.name;
oFormObject.elements["input_8[]"][num+1].value = '0';
num = num + 2;
});
} else {
console.log('error ' );
}
});
}
});
}
</script>
then added a html block and created a button;
<input type="button" class="bluebutton" onclick="getFriends()" value="Get facebook Friends"/>
it seems to work okay, I do something similar to get the name, email, gender and dob of the user to pre-populate those fields for a registration form
Posted 12 years ago on Wednesday March 21, 2012 |
Permalink