我有这个cUrl
curl -X POST \
-H "Authorization: Key {api-key}" \
-H "Content-Type: application/json" \
-d '
{
"inputs": [
{
"data": {
"image": {
"url": "https://samples.clarifai.com/metro-north.jpg"
}
}
}
]
}'\
https://api.clarifai.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs
我想用PHP发出Post请求,这样我就可以得到json响应。 我试过这个:
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPAUTH => $token,
CURLOPT_POSTFIELDS => $img_url,
CURLOPT_URL => 'https://api.clarifai.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs',
CURLOPT_USERAGENT => 'Codular Sample cURL Request'
));
但这不起作用。任何帮助将不胜感激。
错误:
array(1) { ["status"]=> array(3) { ["code"]=> int(11102) ["description"]=> string(15) "Invalid request" ["details"]=> string(28) "Malformed or invalid request" } }