title: send POST request in PHP to pushbullet API 401 error
body: <p>I'm trying to send simple push notifications with pushbullet just through using the email and sending those to the linked account to avoid needing account data. (see reference here: <a href="https://docs.pushbullet.com/#pushes" rel="nofollow noreferrer">https://docs.pushbullet.com/#pushes</a>)</p>
  
  <p>Therefore I'm using a non cURL-method in php that I (not only) found here:
  <a href="https://stackoverflow.com/questions/5647461/how-do-i-send-a-post-request-with-php">How do I send a POST request with PHP?</a></p>
  
  <p>Unfortunately I get back an error as following:</p>
  
  <pre><code>&lt;br /&gt;
  &lt;b&gt;Warning&lt;/b&gt;:  file_get_contents(https://api.pushbullet.com/v2/pushes): failed to open stream: HTTP request failed! HTTP/1.0 401 Unauthorized
   in &lt;b&gt;/path/to/function.php&lt;/b&gt; on line &lt;b&gt;42&lt;/b&gt;&lt;br /&gt;
  bool(false)
  </code></pre>
  
  <p>Option to use urls for file_get_contents is set to "on".</p>
  
  <p>My code:</p>
  
  <pre><code>$pushdata = array(
      "email"     =&gt; $email,
      "type"      =&gt; "link",
      "title"     =&gt; "Demo Pushbullet Notification",
      "body"      =&gt; "You have new comment(s)!",
      "url"       =&gt; "http://demo.example.com/comments"
  );
  
  //Post without cURL
  
  $options = array(
      'http' =&gt; array(
          'header'  =&gt; "Content-type: application/x-www-form-urlencoded\r\n"."Authorization: Bearer &lt;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&gt;\r\n",
          'method'  =&gt; 'POST',
          'content' =&gt; http_build_query($pushdata),
      ),
  );
  $context  = stream_context_create($options);
  $result = file_get_contents("https://api.pushbullet.com/v2/pushes", false, $context, -1, 40000);
  var_dump($result);
  </code></pre>
  
  <p>EDIT: Altered the code to christopherhesse's response, still doesn't work. It also shouldn't require access-tokens as I understand that pushing. I understand it as pushing notification from neutral to an linked email. Maybe I'm wrong, but the access-token doesn't fix it.</p>
  
  <p>EDIT(solved): An access-token <strong>IS</strong> needed to push notifications and as it doesn't work with this method, it does work with cURL.</p>