Hola,
estoy trabajando con la clase babelfish, pero al ejecutarla obtengo un error fatal¡¡¡
Fatal error: Call to undefined function curl_init() in /..../babelfish/babelfish.class.php on line 117
Adjunto el codigo de la clase:
Código PHP:
Ver original<?php
/*******************************************************************************
** Class: babelfish
** Purpose: Translate text using Altavista Babelfish
** Filename: babelfish.class.php
** Author: Vedanta Barooah
** Author Email: vedanta . barooah @ gmail . com
** Date: June 19 2005
** Last Updated: June 27 2007
**
********************************************************************************/
/* if ! PHP5 */
{
foreach ($formdata as $key => $val)
}
}
/* translate text using altavista babelfish */
class babelfish{
/* array to store language names */
var $languages = NULL;
/* stores the altavista babelfish url*/
var $babel_url = NULL;
/* stores the search regex (see readme for details) */
var $search_regex = NULL;
/* stores the data to be posted in an array (see readme for details) */
var $post_data = NULL;
/* stores the supported translation combination(s) */
var $valid_translate = NULL;
/* proxy support
**
*/
var $useProxy = FALSE;
var $proxyServer = NULL;
var $proxyPort = NULL;
var $timeOut = NULL;
/* class constructor */
function babelfish($url=NULL,$postdata=NULL,$regex=NULL){
/* list of languages */
$this->languages = array( 'en' => 'english',
'zh' => 'chinese',
'zt' => 'chinese-traditional',
'nl' => 'dutch',
'fr' => 'french',
'de' => 'german',
'el' => 'greek',
'it' => 'italian',
'ja' => 'japanese',
'ko' => 'korean',
'pt' => 'portuguese',
'ru' => 'russian',
'es' => 'spanish'
);
/* list of valid translations */
$this->valid_translate=array( 'zt_en','en_zh','en_zt','en_nl','en_fr',
'en_de','en_el','en_it','en_ja','en_ko',
'en_pt','en_ru','en_es','nl_en','nl_fr',
'fr_en','fr_de','fr_el','fr_it','fr_pt',
'fr_nl','fr_es','de_en','de_fr','el_en',
'el_fr','it_en','it_fr','ja_en','ko_en',
'pt_en','pt_fr','ru_en','es_en','es_fr'
);
/* babelfish service url */
if($url!=NULL)
$this->babel_url=$url;
else
$this->babel_url="http://babelfish.altavista.com/tr";
/* data that is posted to the babelfish site */
if($postdata!=NULL)
$this->post_data=$postdata;
else
'doit'=>'done',
'intl'=>'1',
'tt'=>'urltext',
'trtext'=>NULL,
'lp'=>NULL
);
/* search for the translated text using this regex */
if($regex!=NULL)
$this->search_regex=$regex;
else
#$this->search_regex='/<td bgcolor=white class=s><div style=padding:10px;>(.*)<\/div><\/td>/';
$this->search_regex='/<td bgcolor=white class=s><div style=padding:10px;>(.*)<\/div><\/td>/sm';
}
/* set proxy settings */
function setProxy($proxyServer, $proxyPort, $timeOut=15){
$this->useProxy = true;
$this->proxyServer = $proxyServer;
$this->proxyPort = $proxyPort;
$this->timeOut = $timeOut;
}
/* perform babelfish translation */
function translate($text,$from_language,$to_language,$forceUTF8=true){
if(!$f){die("***error: source language not found");} if(!$t){die("***error: result language not found");} $l=$f.'_'.$t;
if(!in_array($l,$this->valid_translate)){die("***error: cant translate with given combination ($l)");} $this->post_data['trtext']=$text;
$this->post_data['lp']=$l;
curl_setopt($ch, CURLOPT_USERAGENT
, "Mozilla/5.0 (babelfish.class.php)"); /* use proxy if required */
if($this->useProxy){
curl_setopt($ch,CURLOPT_PROXY
,$this->proxyServer.":".$this->proxyPort); }
$result=preg_match($this->search_regex,$output,$match); }else{
return '** error : babelfish.class.php returned nothing';
}
}
}
/* end of class */
?>
Esta claro que la funcion curl_init() no esta definida, pero ¿como puedo
utilizar el metodo translate en mi codigoPHP, si este hace uso de la funcion curl_init()??
¿alguien me puede ayudar a
solucionar este error?