title: Post Image to localbitcoin contact
body: <p>I am trying to post an image (attachment) and message from local database to localbitcoins trade chat, but it is returning me an error. Yes, API keys are valid and working with other methods.</p>
  <pre><code>{&quot;error&quot;: {&quot;message&quot;: &quot;HMAC authentication key and signature was given, but they are invalid.&quot;, &quot;error_code&quot;: 41}}
  </code></pre>
  <p>I'm not sure what I'm doing wrong here. Can someone please tell me?</p>
  <pre><code>    $path = '/api/contact_message_post/'.$contact_id.&quot;/&quot;;    
      
      $key= $this-&gt;API_AUTH_KEY;
      $secret= $this-&gt;API_AUTH_SECRET;      
   
      $array_mt = explode(' ', microtime());   
      $nonce = $array_mt[1].substr($array_mt[0], 2, 6);   
   
      $post = &quot;&quot;;
      if ($req) {
         $post=http_build_query($req);
      }
      $postdata=$nonce.$key.$path.$post; 
   
      $sign = strtoupper(hash_hmac('sha256', $postdata, $secret)); 
     
      $headers = array(
         'Apiauth-Signature:'.$sign,
         'Apiauth-Key:'.$key,
         'Apiauth-Nonce:'.$nonce,
         'Content-type: multipart/form-data'
      );
  
      $ch = null;
      $ch = curl_init('https://localbitcoins.com'.$path); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, &quot;POST&quot;);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
      $res = curl_exec($ch);
      dd($res);
      if ($res === false) throw new \Exception('Curl error: '.curl_error($ch));
      $dec = json_decode($res, true);   
      if (!$dec) throw new \Exception('Invalid data: '.$res);
      curl_close($ch);   
      return $dec;
  </code></pre>
  <p>I'm trying to add attachment to post data like this.</p>
  <pre><code>$data = array(
              'document' =&gt; new \CURLFile(
                  $_SERVER['DOCUMENT_ROOT'].'\attachments\\'.$attachment, 
                  'image/jpeg',
                  $attachment
              ),
              'msg' =&gt; $messages[0]-&gt;message,
          );
  </code></pre>