【发布时间】:2017-07-21 09:57:56
【问题描述】:
我知道有一个由个人 (https://github.com/tgallice/wit-php) 创建的库。但是,我找不到他是如何格式化卷曲的。我只想做一个请求,所以使用他的库会是大材小用。
这是在终端中工作的字符串,但我不确定如何用 PHP 编写:curl -H 'Authorization: Bearer ACCESSCODE' 'htps://api.wit.ai/message?v=20160526&q=mycarisbroken'
我试过了,但它不起作用:
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL,"htps://api.wit.ai/message?v=20160526&q=my%20car%20doesnt%20work");
curl_setopt($ch1, CURLOPT_POST, 1);
// curl_setopt($ch1, CURLOPT_POSTFIELDS,$vars); //Post Fields
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
$headers = [
'Authorization: Bearer ACCESSCODEOMITTED',
];
curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch1);
curl_close($ch1);
Data::$answer = json_decode($server_output)['entities']['intent'][0]['value'];
【问题讨论】: