I’m trying to get a PHP script to work when I call a table with a GET. I want to modify the JSON response to meet the format needed by my mobile app to display the information.
I have put this script on my service Dining as a table get post process ( dining._table.RightNow.get.post_process). The intent is to get it to return the JSON in a way that can be consumed in the mobile app tool.
Here is my php:
###########################
$data = event.response.content;
$info = json_decode($data);
ob_start();
echo ’
{
“metadata”: {
“version”: “1.0”
},
“content”: [
{
“elementType”: “portlet”,
“navbarTitle”: “Dining Budget”,
“height”: “medium”,
“content”: [
{
“elementType”: “carousel”,
“items”: [
{
“title”: “As of: ‘.$info->AsOf.’ ?>”,
“subtitle”: “Status: ‘.$info->budgetstatus.’”,
“subtitle”: “Spend: ‘.$info->Spent.’”,
“image”: {
“url”: “https://s3.amazonaws.com/gwmobile/’.$info->image.’.jpg”
}
},
{
“title”: “Details”,
“subtitle”: “Average Daily Spend: ‘.$info->DailyAvg.’”,
“subtitle”: “Daily Budget Amount: ‘.$info->DailyBudget.’”
}
]
}
]
}
]
}
’
;
$myStr = ob_get_contents();
return $myStr;
ob_end_clean();
###########################
I’m sure I’m just not thinking clearly. My hope is to use this for students in my course, which is a business students that won’t be strong at programming and system administration. DreamFactory would work great for them to connect a mobile app provided this PHP can work.
Thanks,
Mark