Hi!
I recently discovered Alfred and immediately bought the Powerpack. I'm loving it.
I made my first workflow that allows me to look for synonyms on a french website called Synonymo.
Here's the code :
require("workflows.php");
$wf = new Workflows();
$word = "{query}";
$url = "http://www.synonymo.fr/synonyme/".$word;
$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 works like a charm, except with words containing accented characters, in which case i get the error :
Warning: file_get_contents(http://www.synonymo.fr/synonyme/eĢtonner): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad request
in Command line code on line 7
I tried urlencode() on the word and on the whole url, doesn't work (note that synonymo.fr shows non-encoded accented characters in the url) . I tried using $wf->request() instead of file_get_contents(), doesn't work either.
Also, the exact same code works when run from a php file on my MAMP server (see attachment).
I tried a lot of things, to no avail. Any help would be greatly appreciated