Can't get public API to work

Hello!

I only just learned about LanguageTool and saw that there is a HTTP API. Testing it out in my browser works fine but when I try send a POST request with curl I keep getting a “503 Service Unavailable”.

Does anyone know what I’m doing wrong? Am I missing something?

I’m using PHP.

		$url = 'https://languagetool.org:8081/';
		$payload = 'language=en-US&text=a+simple+test';
 
		// Send
		$curl = curl_init($url);
		curl_setopt($curl, CURLOPT_HEADER, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_SSLVERSION, 3);
		curl_setopt($curl, CURLOPT_POST, true);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
		$response = curl_exec($curl);

I’m not very experienced with curl but even doing a file_get_contents() doesn’t work.

This works for me with PHP 5.3.10:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://languagetool.org");
curl_setopt($curl, CURLOPT_PORT, 8081);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
#curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($curl);
print $response;

Thanks for the quick reply!

I tested out your snippet and it didn’t work either. After some more testing I tried it on a different server where it did work! So something is wrong on my end (i’m still not sure what).

Thanks again!

Have you set error_reporting(E_ALL)? It might give more useful error messages.