# Trying to get PHP script working on a Get PostProcesing

**URL:** <https://community.dreamfactory.com/t/trying-to-get-php-script-working-on-a-get-postprocesing/4601>\
**Category:** Server-Side Scripting\
**Created:** [August 28, 2018, 5:28pm UTC](https://community.dreamfactory.com/t/trying-to-get-php-script-working-on-a-get-postprocesing/4601 "2018-08-28T17:28:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwmalbert](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@gwmalbert](https://community.dreamfactory.com/u/gwmalbert)\
**Post date:** [August 28, 2018, 5:28pm UTC](https://community.dreamfactory.com/t/trying-to-get-php-script-working-on-a-get-postprocesing/4601/1 "2018-08-28T17:28:10Z")

</div>

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](https://s3.amazonaws.com/gwmobile/'.%24info-%3Eimage.'.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

---

<div class="post-metadata">

**Author:** ![Kevin\_Mcgahey](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@Kevin\_Mcgahey](https://community.dreamfactory.com/u/Kevin_Mcgahey)\
**Post date:** [August 28, 2018, 6:29pm UTC](https://community.dreamfactory.com/t/trying-to-get-php-script-working-on-a-get-postprocesing/4601/2 "2018-08-28T18:29:05Z")

</div>

Hi @gwmalbert,

Can you confirm you have ‘_can modify response_’ checked? If that is not the problem can you please show the error.

Thank you,  
Kevin

---

<div class="post-metadata">

**Author:** ![gwmalbert](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@gwmalbert](https://community.dreamfactory.com/u/gwmalbert)\
**Post date:** [August 28, 2018, 6:43pm UTC](https://community.dreamfactory.com/t/trying-to-get-php-script-working-on-a-get-postprocesing/4601/3 "2018-08-28T18:43:14Z")

</div>

Yes - the can modify response flag is checked. The script is set to active as well.

I’m not getting an error. I just not getting this script to execute at all. Whenever I go to the endpoint through the API Docs or through Postman it returns the same JSON response I get if the script isn’t even there.

########## Output from API Docs #############

[https://35.171.xxx.xx/api/v2/dining/\_table/RightNow](https://35.171.xxx.xx/api/v2/dining/_table/RightNow)

Server response  
Code Details  
200   
Response body

{  
“resource”: [  
{  
“NetID”: “abateman”,  
“budgetstatus”: “Over Budget”,  
“AsOf”: “August 07 2018”,  
“Spent”: 64.11,  
“DailyAvg”: “21.37”,  
“DailyBudget”: 18,  
“image”: “red”  
},  
{  
“NetID”: “malbert”,  
“budgetstatus”: “Over Budget”,  
“AsOf”: “August 07 2018”,  
“Spent”: 127.03,  
“DailyAvg”: “42.34”,  
“DailyBudget”: 9.99,  
“image”: “red”  
},  
{  
“NetID”: “nbarbic”,  
“budgetstatus”: “Over Budget”,  
“AsOf”: “August 07 2018”,  
“Spent”: 189.4,  
“DailyAvg”: “63.13”,  
“DailyBudget”: 15,  
“image”: “red”  
}  
]  
}

Response headers

cache-control: no-cache, private connection: Keep-Alive content-type: application/json date: Tue, 28 Aug 2018 18:40:37 GMT keep-alive: timeout=5, max=100 server: Apache transfer-encoding: chunked vary: Cookie x-frame-options: SAMEORIGIN x-powered-by: PHP/7.0.30

---

<div class="post-metadata">

**Author:** ![Kevin\_Mcgahey](https://avatars.discourse-cdn.com/v4/letter/k/b3f665/32.png) [@Kevin\_Mcgahey](https://community.dreamfactory.com/u/Kevin_Mcgahey)\
**Post date:** [August 28, 2018, 7:56pm UTC](https://community.dreamfactory.com/t/trying-to-get-php-script-working-on-a-get-postprocesing/4601/4 "2018-08-28T19:56:41Z")

</div>

@gwmalbert I will bring this up with our engineers and get back to you as soon as possible.
