Using CURL with PHP to send POST field data using http header Authentication

Okay, so until now I had been using api keys passed through the post fields but on a more recent project I was asked to send the api key through the headers when making the request, so I have made myself a little function to use curl and pass the api key through CURLOPT_HTTPHEADER.

This will be the call to your curl function and you can print out the results of the call.