I'm trying to make a php Curl call to formstack api, but I get nothing
- by Oskar Calvo
This is one of my first curls code, so it can have mistakes
I'm trying to be able to make calls to form/:id/submissions
https://www.formstack.com/developers/api/resources/submission#form/:id/submission_GET
If I load:
https://www.formstack.com/api/v2/form/1311091/submission.json?oauth_token=44eedc50d015b95164897f5e408670f0&min_time=2012-09-01%2000:01:01&max_time=2012-10-27%2000:01:01
If works great.
If I try this code:
<?php
$host = 'https://www.formstack.com/api/v2/';
// TODO this should manage dinamics values or build an action in every method.
$action = 'form/1311091/submission.json';
$url = $host . $action;
// TODO this values will arrive like an array with values
$postData['oauth_token']= '44eedc50d015b95164897f5e408670f0';
$postData['min_time'] ='2012-09-01 00:01:01';
$postData['max_time'] ='2012-10-27 00:01:01';
// TODO make a method with this action
function getElements($postData)
{
$elements = array();
foreach ($postData as $name=>$value) {
$elements[] = "{$name}=".urlencode($value);
}
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $elements);
$result = curl_exec($curl) ;
curl_close($curl);
var_dump($result);
?>