Learning platform.api.get


#1

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.


#2

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

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


#3

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

http://wiki.dreamfactory.com/DreamFactory/Tutorials#PHP


#4

Thanks for the responses. This tutorial 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?