# Learning platform.api.get

**URL:** <https://community.dreamfactory.com/t/learning-platform-api-get/2392>\
**Category:** Server-Side Scripting\
**Created:** [March 23, 2016, 1:49am UTC](https://community.dreamfactory.com/t/learning-platform-api-get/2392 "2016-03-23T01:49:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirk](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Kirk](https://community.dreamfactory.com/u/Kirk)\
**Post date:** [March 23, 2016, 1:49am UTC](https://community.dreamfactory.com/t/learning-platform-api-get/2392/1 "2016-03-23T01:49:29Z")

</div>

I’m trying to get my feet wet here with Custom Script Services written in PHP; I just want to call the built in mysql service from my custom script. This is all the code I thought I’d need:

$thing = platform.api.get(‘mysql/\_table’);  
return $thing;

Obviously, I’m wrong, because this is the $thing that I get:

OUTPUT:  
“platformapi”

Please save me from another late-night encounter between my head and the wall.

---

<div class="post-metadata">

**Author:** ![viraf](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/viraf/32/539_2.png) [@viraf](https://community.dreamfactory.com/u/viraf)\
**Post date:** [March 23, 2016, 9:11am UTC](https://community.dreamfactory.com/t/learning-platform-api-get/2392/2 "2016-03-23T09:11:56Z")

</div>

Check out this blog post it has examples to custom scripting services.

> **[DreamFactory 2.1 lets you put some Swagger in your custom scripting services...](https://blog.dreamfactory.com/put-some-swagger-in-your-dreamfactory-custom-scripting-services/)**
>
> DreamFactory provides the ability to create custom scripting services that can be invoked from the REST API. These can be written in JavaScript (V8js or Node.js) or PHP. You can use these services to implement business logic or combine multiple API...

Hope you have created the appropriate user role and provided necessary access to the mysql service.

---

<div class="post-metadata">

**Author:** ![toddappleton](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/toddappleton/32/159_2.png) [@toddappleton](https://community.dreamfactory.com/u/toddappleton)\
**Post date:** [March 23, 2016, 12:44pm UTC](https://community.dreamfactory.com/t/learning-platform-api-get/2392/3 "2016-03-23T12:44:23Z")

</div>

We have some PHP examples here. The last one shows how to use platform.api.

[https://wiki.dreamfactory.com/DreamFactory/Tutorials#PHP](https://wiki.dreamfactory.com/DreamFactory/Tutorials#PHP)

---

<div class="post-metadata">

**Author:** ![Kirk](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Kirk](https://community.dreamfactory.com/u/Kirk)\
**Post date:** [March 23, 2016, 3:55pm UTC](https://community.dreamfactory.com/t/learning-platform-api-get/2392/4 "2016-03-23T15:55:30Z")

</div>

Thanks for the responses. [This tutorial](https://wiki.dreamfactory.com/DreamFactory/Tutorials/PHP_SQL_with_NoSQL) lead us down the right path. Here’s my working result without all the extra fluff:

$test = $platform[‘api’];  
$get = $test-\>get;  
$thing = $get(‘mysql/\_table’);  
var\_dump($thing);  
exit;

I believe we had the roles set correctly, but just for those who are on the same learning curve…this is what I think I know about that:

1. Make sure you have a role assigned to the service you are trying to use and that under the access tab you select the “script” requester option.
2. Make sure whatever app api key you are trying to use has that role assigned to it

And since I have your attention and I’m in a sharing mood, may I suggest [this DF wiki page](https://wiki.dreamfactory.com/DreamFactory/Features/Scripting)?
