Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graph API - get JSON data without "paging" key

I'm getting facebook data using graph api, adding fields in string and get JSON result.

Example:

https://graph.facebook.com/me?fields=music

But JSON returned contains a "paging" key and I do not I want this key.

{ "music":{
  "data":[
     {
        "name":"",
        "category":"",
        "id":"",
        "created_time":""
     },
     {
        "name":"",
        "category":"",
        "id":"",
        "created_time":""
     }
  ],
  "paging":{
     "next":"https://graph.facebook.com/me?fields=music&method=GET&metadata=true&format=json&callback=___GraphExplorerAsyncCallback___&access_token=...&limit=5000&offset=5000&__after_id=..."
  }}}

EDITED:

I'm using Java API (restfb.com) to get JSON.

The command in java is:

FacebookClient client = new DefaultFacebookClient("ACCESS_TOKEN_HERE");
JsonObject rMusic = client.fetchObject("ID_HERE", JsonObject.class, Parameter.with("fields", "id,name,religion,birthday,music"));

How do I avoid it or remove it?

like image 408
vctlzac Avatar asked Jul 15 '26 15:07

vctlzac


1 Answers

When you have your Javascript object built from the JSON, just pay attention to the array of data: result.music.data

And forget about the paging property: result.music.paging

Remember, there's no law in coding that you have to look at every property in your scripts.

like image 169
DMCS Avatar answered Jul 18 '26 11:07

DMCS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!