I am getting below error in google translator api while tranlating a webpage content. Please let me know how to get rid of the following error.
making curl request giving below error
<?php
CURLOPT_URL =>
"https://translation.googleapis.com/language/translate/v2?key=KEY",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => data,
CURLOPT_HTTPHEADER => array('X-HTTP-Method-Override: GET'),
CURLOPT_CONNECTTIMEOUT => 60,
CURLOPT_TIMEOUT =>60,
));
?>
response
{
error: {
code: 400,
message: "Text too long",
errors: [
{
message: "Text too long",
domain: "global",
reason: "invalid"
}
]
}
}
{
error: {
code: 400,
message: "Text too long",
errors: [
{
message: "Text too long",
domain: "global",
reason: "invalid"
}
]
}
}
If you read the error message it states "Text too long"
There is a limit to how much data can be translated at a time. If memory serves that limit is around 5,000 characters.
Solution send less data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.