PHP code example of maxbeckers / google-actions-php
1. Go to this page and download the library: Download maxbeckers/google-actions-php 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/ */
maxbeckers / google-actions-php example snippets
use MaxBeckers\GoogleActions\Request\Request;
...
$requestBody = file_get_contents('php://input');
$googleRequest = Request::fromGoogleRequest($requestBody);
use MaxBeckers\GoogleActions\Validation\RequestValidator;
...
$validator = new RequestValidator();
$validator->validate($googleRequest);
use MaxBeckers\GoogleActions\RequestHandler\RequestHandlerRegistry;
...
$requestHandlerRegistry = new RequestHandlerRegistry();
$requestHandlerRegistry->addHandler($myRequestHandler);
use MaxBeckers\GoogleActions\RequestHandler\RequestHandlerRegistry;
...
$requestHandler = $requestHandlerRegistry->getSupportingHandler($googleRequest);
$response = $requestHandler->handleRequest($googleRequest);
public function supportsRequest(Request $request): bool
{
return true; // check request data
}
use MaxBeckers\GoogleActions\Helper\ResponseHelper;
...
/** @var ResponseHelper */
private $responseHelper;
...
public function handleRequest(Request $request): Response
{
// todo set needed response data
return $responseHelper->respond('Success :)');
}
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.