0

I'm trying to acces the amount of people going on a public event in facebook. I've read through the docs of how to initialise the FB.api but when I try to run the code I get-

"Uncaught SyntaxError: Unexpected identifier" on line 29 (var going)

$(document).ready(function(){
    $('#dataButton').click(getFacebookData);
    $("input").keypress(function(event) {
        if (event.which == 13) {
           event.preventDefault();
           getFacebookData();
        }
    });
    $.getScript('//connect.facebook.net/en_UK/all.js', function(){
       FB.init({
          appId: 'XXXXXXXXXX',
       });     
       $('#loginbutton,#feedbutton').removeAttr('disabled');
       FB.getLoginStatus(updateStatusCallback);
    });
 });

//variables --> array goes here


function getFacebookData() {
    //variables
    var url = $('#url').val();
    var going = FB.api('/'url'/attending', function(response){console.log(response)});
    $('#text').append(going);
};

does anyone know what I'm doing wrong? thanks in advance

1 Answer 1

0

Change -

var going = FB.api('/'url'/attending', function(response){console.log(response)});

to-

var going = FB.api('/'+url+'/attending', function(response){console.log(response)});

(note the + sign, to concatenate a string and a variable)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.