Jump to content

[SOLVED] using cURL to post to a form on GOOGLE


dsaba

Recommended Posts

Hello I need help trying to post to a google form

the url of the form is here:

http://google.com/translate_t

 

There are a couple hidden input types, but the only two which are user filled in are

'text' and 'langpair'

 

the hidden fields are 'hl' and 'ie', tried posting all and only posting the non-hidden ones

I keep getting a google error page of illegal access or error, which means its has not been successfully been posted too

Can anyone help me post successfully to this form with cURL or tell me what i'm doing wrong?-thanks

 

here's what I did with php:

<?php
// create a new curl resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://google.com/translate_t");

// Do a POST
$text = 'hello';
//$data = array('text' => $text, 'langpair' => 'en|ar', 'hl' => 'en', 'ie' => 'UTF8');
$data = array('text' => $text, 'langpair' => 'en|ar');

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

// grab URL, and print
curl_exec($ch);
?>

Link to comment
Share on other sites

  • 2 months later...

$url = "http://translate.google.com/translate_t";

$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 4);

$postdata="hl=en&ie=UTF8&langpair=en|".$lang."&text=".$text;
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);

$result= curl_exec ($ch);
curl_close ($ch);

 

This works, However, this has a problem also... the utf8 does not display properly on foreing languages...

Any help?

 

Using

 

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml','Accept-Charset: UTF-8')); 

 

Results in a error.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.