Having trouble using cURL's PUT in PHP <p>I am having trouble doing cURL PUT in PHP for a REST API. It says 401 Unauthorized and I am quite new to php so I didn't know what to do please help me.</p> <pre><code>&lt;?php $url = "https://app.linkemperor.com/api/v2/vendors/blasts/6949235.json"; $data = '{"blasts": {"links" : "http://doblajemexicano.com.mx/sitio/index.php?title=Keyword_Elite_,_The_Ferrari_Of_Search_phrases_Study http://fi.caravanwiki.com/index.php/Keyword_Elite_,_The_Ferrari_Of_Keywords_and_phrases_Research"}}'; $content = json_encode($data); $oneMB = 1024 * 1024; $fh = fopen('php://temp/maxmemory:$oneMB', 'r+'); fwrite($fh, $content); rewind($fh); $curl = curl_init($url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_USERPWD, "&lt;api key&gt;:x"); curl_setopt($curl, CURLOPT_INFILE, $fh); curl_setopt($curl, CURLOPT_INFILESIZE, strlen($content)); curl_setopt($curl, CURLOPT_PUT, true); curl_setopt($curl, CURLOPT_TIMEOUT, 10); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $json_response = curl_exec($curl); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ( $status != 201 ) { die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl)); } curl_close($curl); $response = json_decode($json_response, true); ?&gt; </code></pre>