Need a detailed example for PHP sandbox
I would like to use PHP-Sandbox to execute Guzzle.
I want: external call -> action Action -> call another remote REST API using Guzzle or something Process results -> return result of bridged call
Unfortunately I don’t see a way of doing this, and I don’t have access to v8 JS engine, so I can’t use those pieces.
I tried setting up a second service to call a different REST API, but i can’t get it to work with an AUHORIZATION token, so I can’t “hook” two actions together.
I tried leveraging / including Guzzle in the PHP code, and got an error - unable to include it.
Thoughts?
Hi Dan, for sure I have just answered on your Google Groups post see: https://groups.google.com/forum/#!topic/fusio/555XNT-wa74
but for a short answer you basically need to:
- Create a new HTTP connection
- Create a new PHP-Sandbox action and use the following PHP code which uses the configured HTTP connection to send a request:
<?php
/** @var \GuzzleHttp\Client */
$client = $connector->getConnection('my-connection');
$resp = $client->request('GET', '/my/path/', [
'headers' => [
'Authorization' => 'Bearer [token]'
]
]);
$data = json_decode((string) $resp->getBody());
return $response->build(200, [], $data);
This also can be closed probably