title: HTTP POST Request on REST API with specific header [PHP]
body: <p>I need to send give some data to rest webservice. I already try to simulate that backend API works correctly but I just don't know how to authorize to that API via HEADER.</p>
  
  <p>In header there should be an:
  <code>Authorization</code> set on <code>Bearer token</code></p>
  
  <p>This is what i did try but without any success.</p>
  
  <pre><code>$host = "www.example.com";
  $path = "/path/to/backend";
  $arr = array('caseNumber' =&gt; '456456787');
  $data = json_encode($arr);
  $token = "ThisIsSomeLongToken";
  
  header("POST ".$path." HTTP/1.1\r\n");
  header("Host: ".$host."\r\n");
  header("Content-type: application/json\r\n");
  header("Authorization: Bearer ".$token." \r\n");
  header("Content-length: " . strlen($data) . "\r\n");
  header("Connection: close\r\n\r\n");
  header($data);
  </code></pre>
  
  <p>I'm new in webservices in PHP so I don't even know if this is correct but it doesn't throw any error and also doesn't do anything with webservice.</p>
  
  <p>May I hope for some lead in PHP REST API with headers?
  Thanks</p>