The solution is to replace
$word = "{query"} by
$word = urlencode(iconv('UTF8-MAC','UTF8', "{query}"));
I found the answer
1: because I saw that urlencode($query} returned "e%CC%81" for the letter "é", it's "e" followed by " ́"
2: via this post which confirmed that :
The complete and cleaned script is now:
require("workflows.php");
$wf = new Workflows();
$word = urlencode(iconv('UTF8-MAC','UTF8', "{query}"));
$url = "http://www.synonymo.fr/synonyme/".$word;
// replace file_get_contents with $wf->request
// it's not better, it's cleaner IMHO
$raw = $wf->request( $url );
// $raw = file_get_contents( $url );
$pattern = '/<a class="word".*>(.*)<\/a>/';
preg_match_all($pattern, $raw, $matches);
foreach ($matches[1] as $key) {
$wf->result( time(), $key, $key, 'Chercher '.$key, 'icon.png', 'yes', $key);
}
echo $wf->toxml();
It took me HOURS to figure this out.