1. Go to this page and download the library: Download skollro/alexa-php-sdk 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/ */
skollro / alexa-php-sdk example snippets
use Skollro\Alexa\Alexa;
use MaxBeckers\AmazonAlexa\Request\Request;
$request = Request::fromAmazonRequest(file_get_contents('php://input'), $_SERVER['HTTP_SIGNATURECERTCHAINURL'], $_SERVER['HTTP_SIGNATURE']);
Alexa::skill('amzn1.ask.skill.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX')
->intent('HelloIntent', function ($request, $response) {
$response->say('Hello');
})
->handle($request, function ($response) {
header('Content-Type: application/json');
echo json_encode($response);
});
class BarIntent
{
public function __invoke($request, $response)
{
$response->say('Use an invokable class as request handler');
}
}
$alexa->launch(function ($request, $response) {
$response->say('Welcome to your skill');
});
$alexa->intent('HelloIntent', function ($request, $response) {
$response->say('Hello world');
});
$alexa->intent('BarIntent', new BarIntent);
$alexa->intent('HelloIntent', function ($request, $response) {
// Basic response
$response->say('Hello world');
// Use cards for showing information in a user's Alexa App
$response->simple($title, $content);
$response->standard($title, $content, $smallImageUrl, $largeImageUrl);
$response->linkAccount();
// Use fluent syntax
$response->say('Link your account')->linkAccount();
});