Das ist das was nicob gepostet hat:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Alexa Text to Speech (TTS) by Lets Smart Home</title>
<style>
table, td, th { border: 1px solid black; }
</style>
</head>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
//Variablen setzen
$cookies="cookies.txt";
$basic_url = 'https://alexa.amazon.de';
$browser = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0";
$user_lang = 'de,nl-BE;q=0.8,en-US;q=0.5,en;q=0.3';
echo "Your Browser is ".$_SERVER['HTTP_USER_AGENT']."<br>Your User Lang is: ".$_SERVER['HTTP_ACCEPT_LANGUAGE']."<br> When you have any trouble with this script open Alexa.php and replace this two data in the alexa.php -> user_lang and browser <br><br>";
if(isset($_GET['device_name'])) {
$device_name = $_GET['device_name'];
}
if(!file_exists($cookies)) die($cookies.' is not available in the order please attach and follow our instructions:');
$cookie_file_ok = 0;
if ( $check_cookie_file = file($cookies) ) {
foreach($check_cookie_file as $check_cookie_file_data) {
if(strpos($check_cookie_file_data,".amazon.de")!==false) {
$cookie_file_ok = 1;
}
}
}
if($cookie_file_ok == 0) die('Your '.$cookies.' does not seem to be okay Please check');
if (!function_exists('curl_init')) {
echo "Curl is not enabled or installed on your web server at Synlogy: Webstation -> Php Settings -> Edit Php Profile -> choose the checkbox at extensions & curl";
}
function clear_string($str, $how = '_'){
$search = array("ä", "ö", "ü", "ß", "Ä", "Ö",
"Ü", "&", "é", "á", "ó",
" :)", " :D", " :-)", " :P",
" :O", " ;D", " ;)", " ^^",
" :|", " :-/", ":)", ":D",
":-)", ":P", ":O", ";D", ";)",
"^^", ":|", ":-/", "(", ")", "[", "]",
"<", ">", "!", "\"", "§", "$", "%", "&",
"/", "(", ")", "=", "?", "`", "´", "*", "'",
"_", ":", ";", "²", "³", "{", "}",
"\\", "~", "#", "+", ".", ",",
"=", ":", "=)");
$replace = array("ae", "oe", "ue", "ss", "Ae", "Oe",
"Ue", "und", "e", "a", "o", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "");
$str = str_replace($search, $replace, $str);
$str = strtolower(preg_replace("/[^a-zA-Z0-9]+/", trim($how), $str));
return $str;
}
// Geräte lesen
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,''.$basic_url.'/api/devices-v2/device?cached=false');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$get_devices = curl_exec($ch);
$get_devices_info = curl_getinfo($ch);
curl_close($ch);
if($get_devices_info['http_code'] == 200) {
if(strpos($get_devices,"Anmelden")!==false) {
echo 'Your cookie information has expired or wrong please renew the cookies.txt If this does not help please delete in the browser all cookies then log in again and then you create a new cookies.txt and upload them! When you use Google Chrome and it isn`t work try it with Firefox ';
echo '<br><br>';
die(print_r($get_devices_info));
}
echo "<h1>The following devices are available in your Amazon account</h1>";
echo "<table><tr><th>Name</th><th>serialNumber</th><th>deviceFamily</th><th>deviceType</th><th>deviceOwnerCustomerId</th><th>HTTP REQUEST URL</th></tr>";
$user = json_decode($get_devices);
foreach($user->devices as $mydata) {
if($mydata->deviceFamily == 'WHA') continue;
if($mydata->deviceFamily == 'VOX') continue;
if($mydata->deviceFamily == 'FIRE_TV') continue;
if($mydata->deviceFamily == 'TABLET') continue;
if(isset($device_name) && $device_name == clear_string($mydata->accountName)) {
$serialNumber = $mydata->serialNumber;
$deviceType = $mydata->deviceType;
$deviceOwnerCustomerId = $mydata->deviceOwnerCustomerId;
}
?>
<tr>
<td><?php echo clear_string($mydata->accountName);?></td>
<td><?php echo $mydata->serialNumber;?></td>
<td><?php echo $mydata->deviceFamily;?></td>
<td><?php echo $mydata->deviceType;?></td>
<td><?php echo $mydata->deviceOwnerCustomerId;?></td>
<td>http://<?php echo $_SERVER['HTTP_HOST'];?>/<?php echo $_SERVER['SCRIPT_NAME'];?>?device_name=<?php echo clear_string($mydata->accountName);?>&text_tts=here you can add your text</td>
</tr>
<?php
}
echo "</table>";
echo "<BR><BR>";
} else {
echo "an unknown error has occurred";
}
if(isset($_GET['device_name'])) {
$device_name = $_GET['device_name'];
} else {
die('No Device Name (device_name) selected!');
}
if(isset($_GET['text_tts'])) {
$text_tts = $_GET['text_tts'];
} else {
die('No Text (text_tts) selected!');
}
if(strlen($text_tts) >= 1000) die('You really should not use more than 1000 characters in your text ');
// TTS an amazon Senden
$cookie_amazon_csrf = 0;
if ( $get_cookies = file($cookies) ) {
foreach($get_cookies as $data) {
if(strpos($data,".amazon.de")!==false) {
if(strpos($data,"csrf")!==false) {
$explode = explode('csrf',$data);
$value = (int)str_replace('-','',$explode[1]);
if($value != 0 ) {
$cookie_amazon_csrf = $explode[1];
}
}
}
}
}
if($cookie_amazon_csrf == 0) die('Your "csrf" cookie is not available! The request can not be processed - your cookie.txt is wrong');
$headers = [
'Host: '.str_replace('https://','',$basic_url).'',
'User-Agent: '.$browser.'',
'Accept: */*',
'Accept-Encoding: deflate, gzip',
'DNT: 1',
'Connection: keep-alive',
'Content-Type: application/json; charset=UTF-8',
'Accept-Language: '.$user_lang.'',
'Referer: '.$basic_url.'/spa/index.html',
'Origin: '.$basic_url.'',
'csrf: '.(int)$cookie_amazon_csrf.'',
'Cache-Control: no-cache'
];
$curl_tts = curl_init();
curl_setopt($curl_tts, CURLOPT_URL,''.$basic_url.'/api/behaviors/preview');
curl_setopt($curl_tts, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_tts, CURLINFO_HEADER_OUT, 1);
curl_setopt ($curl_tts, CURLOPT_POST, 1);
curl_setopt($curl_tts, CURLOPT_POSTFIELDS, '{"behaviorId":"PREVIEW","sequenceJson":"{\"@type\":\"com.amazon.alexa.behaviors.model.Sequence\",\"startNode\":{\"@type\":\"com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode\",\"type\":\"Alexa.Speak\",\"operationPayload\":{\"deviceType\":\"'.$deviceType.'\",\"deviceSerialNumber\":\"'.$serialNumber.'\",\"locale\":\"de-DE\",\"customerId\":\"'.$deviceOwnerCustomerId.'\",\"textToSpeak\":\"'.$text_tts.'\"}}}","status":"ENABLED"}');
curl_setopt($curl_tts, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl_tts, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($curl_tts, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($curl_tts, CURLOPT_FOLLOWLOCATION, true);
$send_tts = curl_exec($curl_tts);
$status_tts = curl_getinfo($curl_tts);
if($status_tts['http_code'] == 200) {
echo "<b>Your Text ".$text_tts." was sent to the following device: Name: ".$device_name.", serialNumber: ".$serialNumber.", deviceType: ".$deviceType.", deviceOwnerCustomerId: ".$deviceOwnerCustomerId."</b> ";
} else {
echo "Unfortunately, an error has leaked!";
print_r($status_tts);
}
?>
</body>
</html>
Einfach den Inhalt in eine PHP Datei z.B. alexa.php in einen Unterordner z.B. echotts des webfront/user Verzeichnisses ablegen zusammen mit dem cookies.txt File und dann im Browser aufrufen mit
http://<IPS IP>:3777/user/echotts/alexa.php
Bei mir funktioniert das aber nicht, zumindest nicht auf die Art, wie er dies beschrieben hat. Vielleicht hast Du ja mehr Glück.
Ansonsten ist das zumindest eine Grundlage sich das mal näher anzuschauen, wenn man dies denn nutzten will.