Facebook FQL Question

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-05-02T00:43:08Z Indexed on 2010/05/02 0:47 UTC
Read the original article Hit count: 769

Filed under:
|

I'm trying to use the Facebook Javascript API to run FQL queries, and it works fine if I try and get users by username or uid, but doesn't work when I'm searching by name.

function get_username()
{
    var name = prompt("Enter name: ")        
      FB.api(
      {
        method: 'fql.query',
        query: 'SELECT username FROM user WHERE name in "'+name+'"'
      },
      function(response) {
          var x = response[0].username
        alert('Username is ' + x);
      }
    );
}

I realize that this will probably return multiple users, but I can't figure out how to tell if it's returning multiple users or no users at all, it seems to freeze after trying to get response[0].username.

I'm probably making a beginner mistake but any ideas?

© Stack Overflow or respective owner

Related posts about facebook-api

Related posts about facebook-fql