Support

Home Forums Event Espresso Premium Collecting registrations via api based on date range

Collecting registrations via api based on date range

Posted: July 13, 2013 at 4:24 am

Viewing 3 reply threads


Andrew Kerr

July 13, 2013 at 4:24 am

Hi,

Love the API work that you have done, I’m particularly interested in getting my hands of the questions stuff when that comes out (hopefully in the not too distant future).

Anywho, the plan is to run a script daily that pulls all the registrations information from the previous day but all I get is a blank result.

<code>$start_of_day = date(&quot;Y-m-d%20H:i:s&quot;,mktime(0,0,0,date(&#039;m&#039;),date(&#039;d&#039;),date(&#039;Y&#039;))-(86400));
$end_of_day = date(&quot;Y-m-d%20H:i:s&quot;,mktime(23,59,59,date(&#039;m&#039;),date(&#039;d&#039;),date(&#039;Y&#039;))-(86400));

$qry=null;
$ch = curl_init();
$qry = &quot;?date_of_registration__gt=&quot; . $start_of_day . &quot;&amp;date_of_registration__lt=&quot; . $end_of_day;

$session_url = &quot;http://mbm.org.au/espresso-api/v1/registrations/&quot; . $session_key . &quot;.xml&quot;;

curl_setopt($ch,CURLOPT_URL, $session_url . $qry);

$registrations_result = curl_exec($ch);</code>

And this is the result
<?xml version='1.0'?><response><status><![CDATA[OK]]></status><status_code><![CDATA[200]]></status_code><body><Registrations></Registrations></body></response>

Where am I going wrong? I suspect it might be something to do with using greater than with a date time? Any solutions?

  • This topic was modified 11 years, 3 months ago by Andrew Kerr.
  • This topic was modified 11 years, 3 months ago by Andrew Kerr.
  • This topic was modified 11 years, 3 months ago by Andrew Kerr. Reason: formating with quotes keeps messing up


Dean

July 15, 2013 at 4:09 am

Hi,

My knowledge of the API is somewhat limited but I do know you cant do date time comparators like that.

You need to use the strtotime function and then compare the numerical results.


Andrew Kerr

July 19, 2013 at 5:50 pm

Thanks Dean, that is helpful.

So I’m guessing that my script will need to pull all the results and then check if each registration falls within my date tange?

Is there a more efficient way of doing things that you can think of?

Thanks


Dean

July 20, 2013 at 1:49 am

Hi Andrew,

Not really no, thats how I would go about it, grab an array of the data and loop through it with a foreach to check array data versus the date range test.

Viewing 3 reply threads

The support post ‘Collecting registrations via api based on date range’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso