Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Days Between Date Events
- Get the variables from the URL
- $contact_id (oap contact id)
- $date_a (first event date)
- $date_b (last event date)
- date1 = YYYY-MM-DD
- Calculate the number of calendar days between events.
- Setup your PING URL Like this:
- http://yourdomain.com/daysbetween.php?contact_id=[contact_id]&date1=[First Event Date]&date2=[Last Event Date]
- */
- //GET variables from URL
- $contact_id = $_GET["contact_id"];
- $date_a = $_GET["date1"];
- $date_b = $_GET["date2"];
- //String to Time
- $date_a = strtotime($date_a);
- $date_b = strtotime($date_b);
- //Do math - difference in time between dates in days
- $interval = $date_b - $date_a; //Interval in seconds
- $interval = ($interval / 86400); //Interval in days
- //Pass the interval back to OAP. Change the group and field names as appropriate.
- $data = <<<STRING
- //You must pass the contact ID as an argument to indicate which contact is being updated
- <contact id="$contact_id">
- <Group_Tag name="Days Between">
- <field name="Added Video 1 Watched">$interval</field>
- </Group_Tag>
- </contact>
- STRING;
- $data = urlencode(urlencode($data));
- // Replace the strings with your API credentials located in Admin > OfficeAutoPilot API Instructions and Key Manager
- $appid = "XXXX";
- $key = "XXXX";
- $reqType= "update";
- $postargs = "appid=".$appid."&key=".$key."&return_id=1&reqType=".$reqType. "&data=" . $data;
- $request = "https://api.moon-ray.com/cdata.php";
- $session = curl_init($request);
- curl_setopt ($session, CURLOPT_POST, true);
- curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
- curl_setopt($session, CURLOPT_HEADER, false);
- curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($session);
- curl_close($session);
- header("Content-Type: text/xml");
- echo $response;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement