Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburnette/0e5fc39a6cc2ba65ffdf11d68f56277a to your computer and use it in GitHub Desktop.
Save ryanburnette/0e5fc39a6cc2ba65ffdf11d68f56277a to your computer and use it in GitHub Desktop.
<?php
//https://stackoverflow.com/a/30630753/2535178
$url = 'https://example.com/api/endpoint';
$auth = base64_encode("username:password");
$options = array(
'http' => array(
'method' => 'POST',
'header' => "Authorization: Basic $auth"
)
);
$context = stream_context_create( $options );
file_get_contents( $url, false, $context );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment