<?php require_once 'FormstackApi.php'; $coords = ''; $wrapper = new FormstackApi('78547558931706ef30202b85cda7f598'); $formId = '2145560'; $count = 0; /* * Function to get latitude and logitude of a location based on address fields. */ function get_lat_long($address, $count) { $address = str_replace(" ", "+", $address); $json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address={$address}&sensor=true"); $json = json_decode($json); if ($json->{'status'} == "OK") { $lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'}; $long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'}; } return array($lat, $long, $count); } /* Calling formstack API getSubmissions for a static form Id */ try { //$forms = $wrapper->getForms(); $subs = $wrapper->getSubmissions($formId, $encryptionPassword = '', $minTime = '', $maxTime = '', $searchFieldIds = array(), $searchFieldValues = array(), $pageNumber = 1, $perPage = 25, $sort = 'DESC', $data = true, $expandData = true); } catch (Exception $e) { echo $e->getCode(); } /* * For each submission record, adding default area of Mysuru, Karnaraka. * Getting the lat and log from Google Map API based upon this address.
/** * Utility method to get a editable submission id * * @return int $submissions[0]->id The id of the first submission found */ private function getEditableSubmissionId() { $wrapper = new FormstackApi(ACCESS_TOKEN); $submissions = $wrapper->getSubmissions(DELETE_SUBMISSION_FORM, '', '', '', array(), array(), 1, 100, 'ASC'); return $submissions[0]->id; }