Search code examples
javascriptfacebookfacebook-graph-apifacebook-javascript-sdkfacebook-like

Get similar pages by category and their likes using Facebook graph API


I am using this link in Facebook grap explorer and it works

https://graph.facebook.com/v2.3/search?q=education?education&type=page

But I am trying to access the same data in the given below code without giving id because id gives an error of non existing feilds

    function Getpage() 
    {
        FB.api("/search?q=education?education&type=page", function (response) {

            });

        }

It does not work but same if I try accessing in that way it gives takes http/graph/facebook/ as id

    function Getpage() 
    {
        FB.api(" /https://graph.facebook.com/v2.3/search?q=education?education&type=page", function (response) {
            var i = 25;
            var g = response.data[i];
        });

        }

It doesn't return the same data as in graph explorer the above link returns.

I tried access token even but using javascript how should I get similar pages of same category? Like this the first link returns in graph explorer

        {
    "data": [
       {
        "category": "Education", 
  "name": "EducationUSA", 
  "id": "72457958318"
}, 
{
  "category": "Education", 
  "category_list": [
    {
      "id": "108051929285833", 
      "name": "College & University"
    }, 
    {
      "id": "163917800330437", 
      "name": "Admissions Training"
    }, 
    {
      "id": "181053558607965", 
      "name": "Youth Organization"
    }
  ], 
  "name": "Education Diffusion", 
  "id": "180364528818411"
   }, 

How to get their likes also?


Solution

  •     function Getpage() 
        { FB.api("https://graph.facebook.com/search?q=education&type=page&access_token=token", function (response) {
            ////    var i = 25;
                //var g = response.data[i];
            });
         }
    

    only add your acess token at token it works guarentee this is a search query