This feature is only available in the Pro Plugin.
Adding dynamic variables into the headers that are sent to your API is possible using the headers_variables parameter.
An example might be that you need to send a base64 encoded authorisation header.
Using Template Tag
Here is how we would dynamically encode the string and send as an Authorization header.
// encode the string
$encoded = base64_encode( $username . ':' . $password );
// call the API using the wpgetapi_endpoint() template tag
$data = wpgetapi_endpoint( 'myapi', 'myendpoint',
array(
'debug' => true,
'header_variables' => array(
'Authorization' => 'Basic ' . $encoded
),
)
);
// you now have the data stored within $data to use however you like
echo $data;
Using Shortcode
Header variables are only available using the template tag.