Я звоню в Watson API так:
$url2 = 'https://watson-api-explorer.mybluemix.net/personality-insights/api/v3/profile?raw_scores=false&csv_headers=false&consumption_preferences=true&version=2017-02-01';
$request_headers = array();
$request_headers[] = 'Accept: application/json';
$request_headers[] = 'Content-Type: text/plain';
$request_headers[] = 'Content-Language: en';
$request_headers[] = 'Accept-Language: en';
$simple_data = 'some really interesting text goes here';
$plain_data = json_encode($data);
$ch2 = curl_init( $url2 );
curl_setopt_array( $ch2, array(
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $simple_data,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_HEADER => $request_headers,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERPWD => 'XXX:YYY' //removed for illustration
)
);
$response2 = curl_exec( $ch2 );
var_dump($response2);
Это продолжает возвращать ошибку следующим образом:
{"code":415,"sub_code":"S00002","error":"Unsupported Content-Type: \"application\/x-www-form-urlencoded\""}
Не уверен, почему этот текст не отправляется правильно и как мне его отправить.
application/x-www-form-urlencoded
. Вы уверены, что пост должен работать? - person Ray Hunter   schedule 21.02.2017