Example #1
0
ini_set('default_socket_timeout', 36000);
ini_set('max_execution_time', 36000);
$words = explode(PHP_EOL, "guerra\ncombattere\nsanguinoso");
$request = new JentiRequestWiktionary($config);
$jenti_word = new JentiWord($config);
ob_implicit_flush(TRUE);
$log = log_open();
foreach ($words as $word) {
    $word_array = $request->get_word($word);
    if ($request->error) {
        echo_msg_flush($request->error);
        log_writeln($log, $request->error);
        continue;
    }
    foreach ($word_array as $word_info) {
        $jenti_word->add_word_and_definitions($word_info);
        if (!$jenti_word->error) {
            echo_msg_flush(print_r($word_info, true));
            log_writeln($log, print_r($word_info, true));
        }
        if ($jenti_word->error) {
            echo_msg_flush($jenti_word->error);
            log_writeln($log, $jenti_word->error);
        }
    }
}
log_close($log);
ob_implicit_flush(FALSE);
?>