我制作了一个测试机器人,它正在使用网络演示集成但是当我尝试使用PHP SDK时它没有响应
这是我的代码
<?php
require_once './vendor/autoload.php';
use DialogFlow\Client;
use DialogFlow\Model\Query;
use DialogFlow\Method\QueryApi;
if(isset($_POST['submit'])){
$query = $_POST['message'];
/*
$postData = array('query' => $query, 'lang' => 'en', 'sessionId' => 123456789);
$jsonData = json_encode($postData);
$ch = curl_init('https://api.dialogflow.com/v1/query?v=20150910');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer 9ceec516365649148a3d2a721d51697a'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
/*$result = $jsonData;
echo $result;*/
/*
try {
$client = new Client('9ceec516365649148a3d2a721d51697a');
$queryApi = new QueryApi($client);
$meaning = $queryApi->extractMeaning('Hello', [
'sessionId' => '1234567890',
'lang' => 'en',
]);
$response = new Query($meaning);
echo $response;
} catch (\Exception $error) {
echo $error->getMessage();
}*/
try {
$client = new Client('c657c6bdd91b4de5a86f2dc3f3e8cbd8');
error_log(print_r($query, TRUE));
$query = $client->get('query', [
'query' => 'Hello',
]);
error_log(print_r($query, TRUE));
$response = json_decode((string) $query->getBody(), true);
error_log(print_r($response, TRUE));
echo $response;
} catch (\Exception $error) {
echo $error->getMessage();
}
}
?>
我正在接收数据到我的文件,WAMP记录没有错误.... 你可以看到我在日志中打印错误只打印了第一个日志,即我收到的消息。 我没有从对话框流中得到任何响应,即使对话框流没有从我接收到的任何数据我已经在训练模块中检查过。请帮忙
感谢您的帮助