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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:10:34+00:00 2026-06-09T16:10:34+00:00

I am in the process of developing a web-based RESTful api for a client.

  • 0

I am in the process of developing a web-based RESTful api for a client. Everything works great apart from one request, in which I need to request the Foursquare API for each row.

The URL for this request is: http://api.example.com/v1/users/times.

Currently the response of a request to that url is:

{
"response": {
    "user": {
        ... some user info ...
        "times": [
            {
                "id": "8",
                "venue_fq_id": "4b81eb25f964a52000c430e3",
                "user_id": "1",
                "wait_length": "4468",
                "created_at": "2012-06-09 21:45:43"
            },
            {
                "id": "9",
                "venue_fq_id": "4aad285af964a520c05e20e3",
                "user_id": "1",
                "wait_length": "8512",
                "created_at": "2012-06-09 21:45:43"
            },
            {
                "id": "10",
                "venue_fq_id": "42377700f964a52024201fe3",
                "user_id": "1",
                "wait_length": "29155",
                "created_at": "2012-06-09 21:45:44"
            },
            {
                "id": "11",
                "venue_fq_id": "45c88764f964a5206e421fe3",
                "user_id": "1",
                "wait_length": "33841",
                "created_at": "2012-06-09 21:45:44"
            },
            {
                "id": "12",
                "venue_fq_id": "430d0a00f964a5203e271fe3",
                "user_id": "1",
                "wait_length": "81739",
                "created_at": "2012-06-09 21:45:44"
            }
        ]
    }
},
"stat": "ok"
}

However, the venue_fq_id being returned in the response.user.times array is relative to a venue on the Foursquare API. I tried running a curl request to the Foursquare API for each row, but the performance is incredibly slow. Please can you give some examples of ways in which I could speed up the performance while retrieving the same information I would had I accessed requested the F/Q API each time?

Here’s my code:

$query = $this->db->query("SELECT * FROM `wait_times` WHERE `user_id` = ?", array($email_address));

$wait_times = $query->result();

foreach ($wait_times as $wait_time) {

    $wait_time->venue = $this->venue_info($wait_time->venue_fq_id);

}

function venue_info($fq_id) {

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.foursquare.com/v2/venues/4b522afaf964a5200b6d27e3");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $response = json_decode(curl_exec($ch));
    curl_close($ch);

    return $response['response']['venue'];

}
  • 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-09T16:10:36+00:00Added an answer on June 9, 2026 at 4:10 pm

    You’re wasting a horrendous amount of time instantiating/tearing down CURL objects. This prevents you from taking advantage of HTTP keep-alives, forcing curl to start a new tcp connection for every request you make.

    Curl handles CAN be reused. e.g.

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    
    
    function venue_info($fq_id) {
       global $ch;
       curl_setopt($ch, CURLOPT_URL, "https://api.foursquare.com/v2/venues/4b522afaf964a5200b6d27e3");
       $resp = curl_exec($ch) or die(curl_error($ch));
       $json = json_decode($resp);
       return($json);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're currently in the process of developing a web-based application which will require the
I'm in the in the process of developing an application for a client, which
We're in the process of developing a WCF REST web service which just receives
I am currently refining my design process for developing websites, scripts, and web-based applications.
I am currently in the process of developing a Web Service which should expose
I am developing an application which is web-based (asp.net MVC). The user configures reminders
I have a web-based documentation searching/viewing system that I'm developing for a client. Part
We are in the process of developing a .NET based IIS hosted web application
we are in process of developing google chrome extension, in which we need to
We are in process of developing an Java based CMS related to travelling domain

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.