Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:29:05+00:00 2026-06-07T03:29:05+00:00

I am using Tornado to get the friends of a user from FB’s API.

  • 0

I am using Tornado to get the friends of a user from FB’s API. The response contains a single page of the results and I want to move to the next page. How do you do that? Do you use facebook_request() again with the relative path parsed from the next page url?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:29:06+00:00Added an answer on June 7, 2026 at 3:29 am

    I haven’t used tornado and the facebook API together before, but Facebook’s response should be formatted like a JSON object, with a ‘paging’ attribute that has ‘next’ and/or ‘previous’ attributes containing urls of other pages (if they exist). So you should be able to just do an http request to get the next page, which will be a JSON response also.

    In your callback function, you should probably be able to parse the friend list and add the friends to your list, then check if there’s a next link; if so, send an async http request to that url, with the callback being the same callback as the original request, otherwise you’ve got all the friends and can do whatever you want with them.

    Edit:
    OK, I haven’t tried this so it might have bugs, but I think it’d be something like:

    @tornado.web.asynchronous
    def get(self):
        self.friends = []
        self.facebook_request("/me/friends", access_token=user["access_token"], callback=self.async_callback(self._save_user_profile))
    
    @tornado.web.asynchronous
    def _save_user_profile(self, stream):
        self.friends += stream['data']
        if stream['paging'].get('next', None) != None:
            next_url = stream['paging']['next']
            #THIS WOULD BE WHERE YOU GET THE NEXT REQUEST
    
        else:
            #THIS WOULD BE WHERE YOU DO WHATEVER YOU WANT WITH THE FRIENDS LIST
    

    Where I commented to do the next request, you should probably first parse the next_url to get all of its parameters (basically split by ‘&’ and then split those by ‘=’ to get names and values of parameters) then pass those to another facebook_request as above. Does that make sense?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Tornado and I have the following code: class UserHandler(RequestHandler): def get(self):
So, I'm using a forever-frame to stream data from Tornado to a JavaScript client
I'm using Tornado and I want to load some static files in the template.
I'm using Tornado web server and want to take advantage of static caching for
Using the http://www.ifans.com/forums/showthread.php?t=132024 post from another question i am allowing the user to enter
I am using tornado.httpclient.AsyncHTTPClient.fetch to fetch domains from list. When I put domains to
Using tornado, I want to create a bit of middleware magic that ensures that
I'm using tornado to fetch many web pages asyncroniously using HTTP proxy . So,
When running a test using the Tornado AsyncHTTPTestCase I'm getting a stack trace that
I'm building a simple web application in tornado.web using mongodb as the backend. 90%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.