Answer the question
In order to leave comments, you need to log in
Yandex.Cloud cannot send a request via php curl, everything works in the console, can you help?
curl -H "X-Client-Request-ID: df55b979-346c-49a1-92c2-ac42730zzzz4" \
-H "Authorization: Bearer token=" \
-d "{\"folder_id\": \"blablablac\", \"texts\": \"классика\", \"sourceLanguageCode\": \"ru\", \"targetLanguageCode\": \"en\"}" \
-X POST "https://translate.api.cloud.yandex.net/translate/v2/translate"
$data = http_build_query([
"sourceLanguageCode" => "ru",
"targetLanguageCode" => "en",
"texts" => "привет",
"folder_id" => $folder_id
]);
$headers = [
"Content-Type: application/json",
"Authorization: Bearer ".$token
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$server_output = curl_exec ($ch);
$info = curl_getinfo($ch);
print_r($info['request_header']);
var_dump($server_output);
curl_close ($ch);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question