Jump to content

fabio_microlopes

Members
  • Posts

    1
  • Joined

  • Last visited

Profile Information

  • First Name
    Fábio
  • Last Name
    Gomes

fabio_microlopes's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi, I have tried to insert a watermark into images through the webservice but without success. I've seen several related topics but still did not get the resolution to my problem. I'm using the Watermark Prestashop Module. Here is the code I use to upload the image in the webservice: function PS_setIMAGE($id_product, $act, $ref, $img = ""){ $image_path = PS_IMGS_PATH.$ref .'.jpg'; $url = PS_SHOP_PATH . '/api/images/products/'.$id_product; if($img <> ""){ $url = $url . '/'. $img. '?ps_method=PUT'; } $result = PS_setIMAGE_execute($url, $image_path); return $result; } function PS_setIMAGE_execute($url, $image_path){ $cfile = getCurlValue($image_path,'image/jpeg','IMAGE.jpg'); $data = array('image' => $cfile); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, array('image'=> new CurlFile($image_path))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); return $result; } function getCurlValue($filename, $contentType, $postname) { // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload if (function_exists('curl_file_create')) { return curl_file_create($filename, $contentType, $postname); } // Use the old style if using an older version of PHP $value = "@{$this->filename};filename=" . $postname; if ($contentType) { $value .= ';type=' . $contentType; } return $value; } Example Execute: PS_setImage('1', 'NEW', 'reference_product'); What am I doing wrong? Prestashop Version: 1.6.1.3 Watermark Module Version: 1.0.4 Best regards, Fábio Gomes
×
×
  • Create New...