Is it possible to send a curl request in jQuery or javascript?
Something like this:
curl
-H 'Authorization: Bearer 6Q************'
'https://api.wit.ai/message?v=20140826&q='
So, in PHP on submission of a form, like this:
$header = array('Authorization: Bearer 6Q************');
$ch = curl_init("https://api.wit.ai/message?q=".urlEncode($_GET['input']));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($ch);
curl_close($ch);
What I'm trying to do is perform this curl request, which returns json and then I plan on parsing it with jQuery's $.get()
function.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…