api - How to use authorization header PHP -
i trying use authorization header in order use vimeo api.
it tells me 'authorization: basic ' + base64(client_id + ':' + client_secret) , can do.
but on internet tell me code? not php, go in php file? if function use on after storing it? go in htaccess file?
it sad how terrible , online documentation on this.
to summarize, im saying show me code
thanks help
$api_url = 'http://myapiurl'; $client_id = 'myclientid'; $client_secret = 'myclientsecret'; $context = stream_context_create(array( 'http' => array( 'header' => "authorization: basic " . base64_encode("$client_id:$client_secret"), ), )); $result = file_get_contents($api_url, false, $context);
documentation links:
for more complex requests, can use curl, library's php implementation mess , prefer avoid when can. guzzle library abstracts lot of complexities here.
Comments
Post a Comment