title: Transform Python code for REST in PHP
body: <p>Once more, I need your help. My client wishes to use a REST server for some data encryption. I have been given a code slice in Python that works. (I don't know Python so I'm gonna trust his word on that). I need to make it work in PHP.</p>
  
  <p>Note: I'm using Windows and XAMPP, so any help would be appreciated if you take this into account. Also the REST server is not the real one, I don't want this public.</p>
  
  <p>I am a newbie in using cURL so not sure what am I missing to make it work. Right now I have an error that states: "Could not resolve host: en.tty.is; No data record of requested type".</p>
  
  <p>Here is the Python code:</p>
  
  <pre><code>input = urllib.urlencode({‘plaintext’: ‘some secret information’})
  cyphertext = urllib2.urlopen(‘https://en.tty.is/encrypt’, input).read()
  </code></pre>
  
  <p>Here is what I've been trying to achieve with cURL 7.24.0 in PHP:</p>
  
  <pre><code>$url ="https://en.tty.is/encrypt";
              $data = json_encode(array('plaintext'=&gt;$txt));
  
              $ch = curl_init();
              curl_setopt($ch,CURLOPT_URL,$url);
              curl_setopt ($ch, CURLOPT_CAINFO, MY_CAINFO_PATH);
              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
              curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);   
              curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
              curl_setopt($ch, CURLOPT_POST, true);
              curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
  
              $chleadresult = curl_exec($ch);
              $chleadapierr = curl_errno($ch);
              $chleaderrmsg = curl_error($ch);
              $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
              curl_close($ch);
  
              if(!$chleadresult){ 
                  echo $chleaderrmsg;die;
              }
  </code></pre>
  
  <p>Much appreciating any help. Thanks!</p>