Doug Staneart
September 14, 2015 at 7:29 am
We have activated the “Espresso JSON API Add-on” plugin in http://www.fearlesspresentations.com/ website.
After that we call api from the http://maketickdemo.com/leadersinstitute/ website. Below is the sample code for fetching the upcoming event from the fearlesspresentations website.
<?php
$curdate = date(“Y-m-d H:i:s”);
$ch = curl_init();
$url = “http://www.fearlesspresentations.com/espresso-api/v1/authenticate/” ;;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$args = array(‘username’=>’*****’, ‘password’ => ‘*******’);
if(!empty($args) )
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
}
$result = curl_exec($ch);
curl_close($ch);
$token = json_decode($result, true);
if(isset($token[‘status’]) && $token[‘status’] == ‘OK’){
$ch = curl_init();
$url1 = “http://www.fearlesspresentations.com/espresso-api/v1/events/” ;.$token[‘body’][‘session_key’].”.json/”;
curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$args = array(‘Datetime.event_start__gt’=>urlencode($curdate), ‘limit’ => 2);
if(!empty($args) )
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
}
$result1 = curl_exec($ch);
curl_close($ch);
$data = json_decode($result1, true);
echo “
"; print_r($data);echo "
“;
}
?>
After implementing the coding we are getting this status.
Arrey
{
[status] => Endpoint not yet implemented
[status_code] => 500
}
Josh
September 14, 2015 at 1:41 pm
Add New Note to this Reply
Hi Doug,
It looks like it’s this part that’s throwing things off:
$args = array(‘Datetime.event_start__gt’=>urlencode($curdate), ‘limit’ => 2);
if(!empty($args) )
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
}
Can you try removing the above, then adding the parameters as querystring variables like this?
$args = '?Datetime.event_start__gt='.urlencode($curdate).'&limit=2';
$url1 = "http://www.fearlesspresentations.com/espresso-api/v1/events/".$token['body']['session_key']."/".$args;