dsaba Posted April 27, 2007 Share Posted April 27, 2007 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 https://forums.phpfreaks.com/topic/49004-solved-using-curl-to-post-to-a-form-on-google/ Share on other sites More sharing options...
dsaba Posted April 27, 2007 Author Share Posted April 27, 2007 google is my friend Link to comment https://forums.phpfreaks.com/topic/49004-solved-using-curl-to-post-to-a-form-on-google/#findComment-240059 Share on other sites More sharing options...
manuel2 Posted July 27, 2007 Share Posted July 27, 2007 $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 https://forums.phpfreaks.com/topic/49004-solved-using-curl-to-post-to-a-form-on-google/#findComment-308558 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.