mzubairsaleem / gtranslate-api-php

Automatically exported from code.google.com/p/gtranslate-api-php
GNU General Public License v3.0
0 stars 0 forks source link

request is too large to process #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. send a large text to translate

google will return a error page because the request send to google is too 
large.
Google will send
<H1>Request-URI Too Large</H1>
The requested URL <code>/ajax/services/language/translate</code>... is too 
large to process.

To fix it, use a POST request instead of GET (I don't think it can works 
with file_get_contents )

In the function urlFormat
remove $url  = $this->url."?";

In the function requestCurl
add
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $url);

Original issue reported on code.google.com by scouzin...@gmail.com on 17 Oct 2009 at 10:33

GoogleCodeExporter commented 8 years ago
I solved with POST in curl to send large text. See attach.

Original comment by tor...@gmail.com on 24 Oct 2009 at 9:44

Attachments:

GoogleCodeExporter commented 8 years ago
This the first time, please consider this code. tnx

Original comment by tor...@gmail.com on 24 Oct 2009 at 9:55

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

Just committed a new version, that allows you to use CURL post methods. The fix 
was based on your code.

If you want to use it just check out the last version from repository.

To use, here is a simple example:
<?php
 require("GTranslate.php");
 $translate_string = 'Das ist';
 $gt = new Gtranslate;
 $gt->setRequestType('curl');
  echo $gt->german_to_english($translate_string)."<br/>";
?>

Just let me know if helps.

Jose

Original comment by josedasilva on 2 Nov 2009 at 10:33

GoogleCodeExporter commented 8 years ago
hi
the code works. 
thanks
stephane 

Original comment by scouzin...@gmail.com on 2 Nov 2009 at 11:06

GoogleCodeExporter commented 8 years ago
This is Melinda  set it up for me 
#1

Original comment by melindam...@gmail.com on 14 Feb 2013 at 6:06

Attachments: