1. Go to this page and download the library: Download codeat3/foaas-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codeat3 / foaas-client example snippets
use Codeat3\FoaasClient\FoaasClient;
$foaasClient = new FoaasClient([
'decency' => 'low',
'responseAs' => 'array', // possible response formats are 'text' (default), 'html', 'xml', 'json', 'array'
]);
print_r($foaasClient->what('John')->get());
// Output
Array
(
[message] => What the f*ck‽
[subtitle] => - John
)
$foaasClient = new FoaasClient([
'decency' => 'low',
]);
echo $foaasClient->what('John')->getAsText(); // What the f*ck‽ - John
echo $foaasClient->what('John')->getAsXml(); // <?xml version="1.0" encoding="UTF-8"
// Implementation
class ObjectResponse implements FoaasResponse
{
protected $acceptHeader = 'application/json';
public function getHeaders():string
{
return $this->acceptHeader;
}
public function response(string $response, FoaasFilter $filter)
{
$response = $filter->filter($response);
return json_decode($response);
}
}
// Use
$foaasClient = new FoaasClient([
'decency' => 'low',
'responseAs' => 'object',
'responseFormats' => [
'object' => ObjectResponse::class,
]
]);
var_dump($foaasClient->what('John')->get());
/*
class stdClass#27 (2) {
public $message =>
string(16) "What the f*ck‽"
public $subtitle =>
string(6) "- John"
}
*/
php
use Codeat3\FoaasClient\FoaasClient;
$foaasClient = new FoaasClient([
'decency' => 'low', // possible decency filter options are 'low', 'medium', 'high', 'extreme' - default is no filter
]);
echo $foaasClient->what('John')->get();
// Output
What the f*ck‽ - John
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.