You need to include "&langpair=%7C$tlang" in your post fields.
Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com http://jgeerdes.blogspot.com http://jgeerdes.wordpress.com [email protected] Unless otherwise noted, any price quotes contained within this communication are given in US dollars. If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com ! On Apr 20, 2009, at 12:00 PM, alicia130 wrote: > > I know this subject has been beaten to death, but bear with me. I > couldn't find the answer to my problem. I am accessing the google > translate with curl thru php, and no matter what i do i keep getting > back the response invalid language pair. Here is my code ($tlang = > the language that I want translated to, $ttext = the text to be > translated. The text will always be translated from english. > > function translate($transText,$tlang){ > define('POSTURL', 'http://ajax.googleapis.com/ajax/services/ > language/translate'); > // INITIALIZE ALL VARS > $ch=''; > $Rec_Data=''; > > $ch = curl_init(POSTURL); > curl_setopt($ch, CURLOPT_POST ,1); > curl_setopt($ch, CURLOPT_POSTFIELDS , > 'q='. urlencode($transText). '&v=1.0&hl='. urlencode($tlang)); > > curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); > curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN > HTTP HEADERS > curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE > CONTENTS OF THE CALL > $Rec_Data = curl_exec($ch); > > > > Thank you in advance for your help!!! > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-AJAX-Search-API?hl=en -~----------~----~----~----~------~----~------~--~---
