API requires a encoded API key, how do i send this with curl?
<p>I am working with an api that requires an api key to be sent in basic auth of a curl call.</p>

<pre><code>    $json = "somedata";
    $url = "http.server.com";
    $key = "someKey";

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERPWD, $key);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/2.0");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    $output = curl_exec($ch);
    curl_close($ch);
</code></pre>

<p>My response is:</p>

<pre><code>    "Server error","data":{"details":"Invalid API key. 
</code></pre>

<p>I know the key itself is correct, It works when sending a curl request not using php.</p>

<p>I assume USERPWD is not the correct curlopt to use, which one is?</p>

<p>From docs:</p>

<p>A Base64 encoded string, generated from the combined username:password
sequence.</p>

<p>In our case, the API key is set as username, and password is set as an empty
string.</p>

<p>For example, if the API Key is equal toN8KzwcqVUxAI1RoPi5jyFJPkPlkDl9vF, </p>

<p>the Base64 encoding should be performed on the following string:
N8KzwcqVUxAI1RoPi5jyFJPkPlkDl9vF:</p>

<p>In this case, the content sent to
the authorization header is
Basic TjhLendjcVZVeEFJMVJvUGk1anlGSlBrUGxrRGw5dkY6.</p>

<p><a href="http://download.bitdefender.com/SMB/Cloud/GravityZone/en_US/Bitdefender_ControlCenter_API-Guide_enUS.pdf" rel="nofollow">API Docs</a></p>