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 8541695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:53:20+00:00 2026-06-11T11:53:20+00:00

I am trying to build a very basic web page using PHP that displays

  • 0

I am trying to build a very basic web page using PHP that displays a Foursquare user’s 800+ tips with their Saved and Like counts in an html table for reporting and analytics purposes. Here is an example of what I mean on foursquare: http://foursquare.com/redbull/list/tips . (Again, redbull is just my example..I am working with an organization that has 812 tips).

Foursquare provides an api to get to this data:

https://api.foursquare.com/v2/lists/{USER-ID}/tips?oauth_token={oauth-token}&limit=200&v=20120917

BUT you can only get 200 results at a time and must use an offset to get the next 200, 400 and so on:

https://api.foursquare.com/v2/lists/{USER-ID}/tips?oauth_token={oauth-token}&limit=200&offset=200&v=20120917

In my case I would need to call the API 5 times to get all 812 tips. I came up with a very clunky and unscalable solution where I do call the API multiple times and just keep creating rows in my table. Here is my ugly but working solution: http://pastebin.com/WL6kdTPY

But obviously as tips continue to grow I would need to keep modifying my code to account for each iteration of 200 more. In the API data I can see a mention of total tips (812) so I feel like I should be able to use that to come up with a more lean solution.

Can anyone help?
Thanks!

  • 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-11T11:53:21+00:00Added an answer on June 11, 2026 at 11:53 am

    A second loop should do the trick :

    <?php 
    
    
    $today = date("Ymd");
    $likes = 0;
    $todo = 0;
    
    $offset = 0;
    $limit = 200;
    do{
        $url="https://api.foursquare.com/v2/lists/{user-id}/tips?oauth_token={oauth_token}&limit=".$limit."&offset=".$offset."&v={$today}";
        $source = file_get_contents($url);
        $obj = json_decode($source, true);
        foreach($obj['response']['list']['listItems']['items'] as $item)
        {
    
            echo "<tr>";
            echo "<td  style = 'width: 75px;'>" .  date('m/d/y', $item['createdAt']) . "</td>" ;
            echo "<td  style = 'width: 200px;'>" . $item['venue']['name'] . "</td>" ;    
            echo "<td  style = 'width: 400px;'>" . $item['tip']['text'] . "</td>" ;
            echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['likes']['count'] . "</td>" ;
            echo "<td  style = 'width: 50px; text-align: center;'>" . $item['tip']['todo']['count'] . "</td>" ;
            echo "</tr>";
            $likes += $item['tip']['likes']['count'];
            $todo += $item['tip']['todo']['count'];
    
        }
        $offset += $limit;
    } while(count($obj['response']['list']['listItems']['items']) >= $limit);
    
    
    ?>
    

    Basicly you check if the number of returned item is lower than the limit for each request. that should mean that you reached the end

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

Sidebar

Related Questions

I am trying to build this very simple (visually speaking) layout using HTML/CSS that
I am trying to build a very basic fulltext search app in php. I
I am currently trying to build a very basic serial shell with my arduino.
I'm trying to write a basic drawing widget using the Tkinter library. The very
I'm trying to build a basic website, but that doesn't limit my ability to
I am trying to build a very basic message center. My idea is to
I would like to build a very basic daily sales report. I'm am trying
I'm trying to build a new web app using Eclipse, I want to use
I'm trying to build VERY basic model->controller->view structure with CodeIgniter. I'd rather use models
I'm trying to build a very basic AutoLisp interface. I'm a total beginner at

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.