phpapiformstack

Formstack api give me back the same json all the time


Edited 05-02-2013. I have updated the curl code.

I have build a small class to work with formstack api. And I think that it works.

The problem is when I try to try all the leads from a form (more than 4000).

I build the urls with its page, time, and per_page param.

The strange is that Formstack give me back all the time the same json.

I have try that urls in a browser and it works great.

https://www.formstack.com/api/v2/form/xxxxxxxx/submission.json?oauth_token=xxxxthisismyoauthtokenxxxxx&per_page=100&min_time=2004-11-18 18:57:45&max_time=2013-02-04 18:57:45&page=0

https://www.formstack.com/api/v2/form/xxxxxxxx/submission.json?oauth_token=xxxxthisismyoauthtokenxxxxx&per_page=100&min_time=2004-11-18 18:57:45&max_time=2013-02-04 18:57:45&page=1

This is my curl code:

public function makeCurlGetCall($url)
{
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_HTTPGET, TRUE);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_HTTPHEADER,array('Content-type: application/json')); 
  curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
  curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookies.txt');
  curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookies.txt');

  $result =  curl_exec($curl);
  curl_close($curl);

  return $result;
}

As I have say, If I run the Curl method in a for loop to build all the page url I get the same json, but If I chech the url in a browser it works great.

Thanks

Oskar


Solution

  • Just Clear your cache and restart your browser. It will work , the browser is caching the response and you are getting the same response each time. Or the other thing may be you can have errors in the loop itself.

    for ($i = 1; $i <=  $lead_decode->pages; $i++)