Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.