0
我知道有個人製作的圖書館(https://github.com/tgallice/wit-php)。但是,我無法找到他如何格式化捲曲。我只想要做一個請求,所以使用他的庫會過度。如何在PHP中格式化curl?
下面是在終端工作的字符串,但我不知道如何用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'];