Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performing facebook searches with javascript API

I have a user's email, and I would like to search for them in Facebook using the javascript api.

I know I need something

FB.api('/search', {q: '[email protected]', type: 'user'}, function(response) {
    //Handle response
});

But this doesn't seem to work, I don't even get a response.

I have also tried putting it inside and/or after a call to FB.login() which just fails for some reason.

Any suggestions? Their documentation for how to use this is so vague.

EDIT:

Here is all of the appropriate code:

<div id="fb-root"></div>
<script type="text/javascript" >
    FB.init({
        appId: 'apikey', //Actual API key removed for obvious reasons
        status: true, // check login status
        cookie: true, // enable cookies to allow the server to access the session
        xfbml: true, // parse XFBML
        oauth: true // enable OAuth 2.0
    });
</script>

<script type="text/javascript" >
    FB.login(function (response) {
        if (response.authResponse) {
            FB.api('/search', {q: '[email protected]', type: 'user'}, function(response) {
            {
                alert(response);
            });
        }
        else {
            alert(response.toString());
        }
    });
</script>
like image 696
Dan F Avatar asked Sep 14 '11 21:09

Dan F


People also ask

What can I do with Facebook API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How is JavaScript used in Facebook?

The Facebook SDK for JavaScript provides a rich set of client-side functionality that: Enables you to use the Like Button and other Social Plugins on your site. Enables you to use Facebook Login to lower the barrier for people to sign up on your site. Makes it easy to call into Facebook's Graph API.


1 Answers

var urlCall = "/search?q=Bamboo&type=page&access_token=";
FB.api(urlCall, function(response) {
  //you code to execute     
});

Finally found this after some digging.

like image 128
MondayPaper Avatar answered Oct 13 '22 00:10

MondayPaper