Facebook Graph API (v2.8): Pagination in JavaScript? -


i'm trying figure out how scrape/access comments in very, long thread (about 1,035 comments). best way go make fb app , use graph api (the raw html opaque! :) )

my problem can control fields receive on first page of results, after i'm missing fields.

is there way control fields see on subsequent pages, using javascript?

after logging in, etc, ask first page of comments using code:

fb.api(     '/168...etc', // hard coding bad, know,                           // right i'm figuring out     'get', {         "fields": "message,type,comments.limit(3){message,like_count,from}",     },     processnominationthread ); 

this works fine - response object processnominationthread function handles well. specifically, each comment object has fields i'm interested in. response object contains fields this:

response: object     comments: object         data: array[3]         paging: object 

a typical comment object looks this:

from: object     id:"1111111...etc"     name:"bob smith"     __proto__:object id:"1680...etc" like_count:2 message:"harry potter , kidney stone teeth" 

this great because i'm interested in message each comment, how many likes had, , (if possible) posted it.

the problem when go next page of results. when use following javascript code:

if (response.comments.paging.next) { // if there's more 1 page     fb.api(         response.comments.paging.next, // next page         'get', {             "fields": "message,type,comments{message,like_count,from}"         },         continueprocessnominationthread     ) } 

then different results. essentially, first time ask comments full response, , each time ask 'next' page 'comments' object overall response. (this part fine - don't need response info subsequent pages).

here's problem: the individual comment objects subsequent (2nd , onward) pages missing every field except 'message' , 'id'

in other words, i'm getting comment objects like:

data[1]: object     id:"168etc"     message:"harry potter , thing found behind safeway dumpsters"     __proto__:object {etc} 

is possible fields on second (and onward) page of pagination?

a couple of thoughts:

on 1 hand write more code individually ask each comment missing fields seems super-inefficient (both me , facebook - want me query them hundreds of times info they'll happily collect me on first page of results?).

i did try asking 10,000 results , fb gives me error message. looks it'll give me 950 results or so, fb starts returning error message around 1,000. asking "all data" in effort side-step pagination looks bit fragile (but ok cases).

there couple of other questions on so, they're either on different topic or else old & outdated (like facebook graph api - paging, recommends dynamically adding <script> elements instead of using current js sdk).

any help, advice, or pointers deeper documentation great (there's no docs (that find) pagination @ all).

just in case curious - turns out fault, after all.

when asking next page of results made following call:

        fb.api(             response.comments.paging.next, // next page             'get',              {                 "fields": "message,type,comments{message,like_count,from}"                 // above line wrong!!!!             },             second_page_of_comments_bug_here         ) 

the correct way not list fields want second+ pages, so:

        fb.api(             response.comments.paging.next, // next page             'get',              { }, // leave empty             second_page_of_comments_bug_here         ) 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -