{"counter":{"mirrors2":[{"site":"test.example.com"},{"site":"test2.example.com"},{"site":"test3.example.com"},{"site":"test4.example.com"},{"site":"test5.example.com"}]}}
HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)добавил
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
теперь код выглядит так:$url = "https://api-metrika.yandex.net/management/v1/counter/$COUNTER_VAR";
$data = '{"counter":{"mirrors2":[{"site":"test.example.com},{"site":"test2.example.com},{"site":"test3.example.com},{"site":"test4.example.com},{"site":"test5.example.com}]}}';
$headers = array(
"Host: api-metrika.yandex.net",
"Authorization: OAuth $TOKEN_VAR",
"Content-Type: application/x-yametrika+json",
"Content-Length: " . strlen($data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_PUT, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
if ($resp === false) {
echo curl_error($curl);
} else {
var_dump($resp);
}
curl_close($curl);
string(389) "{"errors":[{"error_type":"invalid_json","message":"I/O error while reading input message; nested exception is java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 30000/30000 ms"}],"code":400,"message":"I/O error while reading input message; nested exception is java.io.IOException: java.util.concurrent.TimeoutException: Idle timeout expired: 30000/30000 ms"}"
$.each(items, function(index, value) {
image[index] = new Image();
image[index].src = value['src'];
});
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');