$authParams = [ 'username' => 'john', 'password' => 'secret' ]; $authHeader = getAuthorization('Basic', $authParams); echo $authHeader;
$authParams = [ 'client_id' => '123', 'client_secret' => 'abc' ]; $authHeader = getAuthorization('Bearer', $authParams); echo $authHeader;In this example, the function is used to generate an OAuth 2.0 Bearer Token header. The $authParams array contains the client ID and client secret that are used to authenticate the client. The function returns the authorization header as a string, which is then echoed to the output. This function is part of the HTTP-Message package library, which is included in the PHP HTTP extension.