Back to LanguageTool Homepage - Privacy - Imprint

Not getting response from Server

Hi!
I’m sending my textarea text to server request but getting strange error. However I’ve also purchased the LT premium version. Have API key, don’t know where to use it.

Here’s my file code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Checking LT API</title>
</head>
<body>
    <form action="" method="post">
 
      <p id="checktextpara" style=" border: 1px solid #262626; width: 50%;">
          <textarea id="checktext" name="text" style="width: 100%;"
            rows="6" >We are checkin the Languag Tool API</textarea>
      </p>
     
      <div>
          <select name="lang" id="lang">
              <option value="en-US">English</option>
              <option value="de-DE">German</option>
              <option value="it">Italian</option>
          </select>
          <input type="submit" name="submit"
              value="Check Text">
      </div>
     
    </form>                   
</body>
</html>
<?php

if(isset($_POST['submit'])) {
  $var1 = $_POST['text'];
  $var2 = $_POST['lang'];

  $url = 'https://languagetool.org/api/v2/check?text='.$Var1.
  '&language='.$var2;


  $opts = array('http' =>
    array(
      'method' => 'POST',
      'header' => 'Content-type: application/json'
    )
  );

  $context = stream_context_create($opts);

  $result = file_get_contents($url, false, $context);

    echo "<script>console.log('Results: " . $result . "' );</script>";
    echo "<script>console.log('JSON: " . $context . "' );</script>";
}

?>

This is my console & result: