ebarolo Posted April 8, 2014 Share Posted April 8, 2014 Buongiorno, ho un problema a inserire via webservices le immagini dei prodotti su Prestashop 1.6.0.5 la chiamata alle API mi rirona questo XML <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[66]]></code> <message><![CDATA[Unable to save this image]]></message> </error> </errors> </prestashop> la chiamata che faccio è una chiamata http fatta nel seguente modo POST http://192.168.221.122/Store/api/images/products/183 Authorization: Basic VfVMNUlVSFoNFBBQ1ZOUkZCsldCM1Q1SUxYe0RZQks1 Content-Type: application/x-www-form-urlencoded Filename: /Volumes/Storage/Progetti_Italsoftware/4th Dimension/4d_Logo_3D.png è qualche giorno che ci stò sbattendo la testa ma non ne vengo a capo :-( Avete qualche buon consiglio ?? Link to comment Share on other sites More sharing options...
AlbertoV Posted December 24, 2014 Share Posted December 24, 2014 Avevi per caso risolto? Mi sto imbattendo nello stesso identico problema... Link to comment Share on other sites More sharing options...
davidemaglio Posted September 8, 2015 Share Posted September 8, 2015 idem, qualcuno ha risolto il problema? sto cercando di pubblicare con curl ma mi ritorna un errore 500... Link to comment Share on other sites More sharing options...
AlbertoV Posted September 8, 2015 Share Posted September 8, 2015 Io sono riuscito alla fine ad aggiornare le immagini con questo codice: $url = PS_SHOP_PATH. 'api/images/products/'.$prod_id.'/'.$img_id.'?ps_method=PUT'; $cfile = curl_file_create($img_url,'image/jpg'); $data = array('image' => $cfile); $ch = curl_init(); $headers = array("Content-Type:multipart/form-data"); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); Ovviamente le variabili vanno opportunamente modificate. 1 Link to comment Share on other sites More sharing options...
davidemaglio Posted September 8, 2015 Share Posted September 8, 2015 Io sono riuscito alla fine ad aggiornare le immagini con questo codice: $url = PS_SHOP_PATH. 'api/images/products/'.$prod_id.'/'.$img_id.'?ps_method=PUT'; $cfile = curl_file_create($img_url,'image/jpg'); $data = array('image' => $cfile); $ch = curl_init(); $headers = array("Content-Type:multipart/form-data"); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); Ovviamente le variabili vanno opportunamente modificate. Niente, continua a non andare... se utilizzo il curl_file_create la richiesta non parte neanche perché non riesce ad accedere al file, anche se il file è 0777. Se invece uso il vecchio metodo @ mi ritorna un errore 400 1 Link to comment Share on other sites More sharing options...
AlbertoV Posted September 8, 2015 Share Posted September 8, 2015 Sicuro che il path sia corretto? Io posso solo dirti che così mi funziona... Link to comment Share on other sites More sharing options...
davidemaglio Posted September 8, 2015 Share Posted September 8, 2015 Sicuro che il path sia corretto? Io posso solo dirti che così mi funziona... Sì, è corretto. controllato e ricontrollato Link to comment Share on other sites More sharing options...
AlbertoV Posted September 8, 2015 Share Posted September 8, 2015 Il path che indichi è il percorso fisico? /home/..../immagine.jpg oppure www.dominio.com/immagine.jpg ? Io uso il primo formato. Se non risolvi questo problema, temo tu sia già bloccato dall'inizio. Link to comment Share on other sites More sharing options...
davidemaglio Posted September 8, 2015 Share Posted September 8, 2015 (edited) Il path che indichi è il percorso fisico? /home/..../immagine.jpg oppure www.dominio.com/immagine.jpg ? Io uso il primo formato. Se non risolvi questo problema, temo tu sia già bloccato dall'inizio. E' il percorso fisico, glielo passo anche con realpath per essere più sicuro. Non riesco proprio a capire quel 400 da cosa esce... La risposta è sempre <?xml version="1.0" encoding="UTF-8"?><prestashop xmlns:xlink="http://www.w3.org/1999/xlink"><errors><error><message><![CDATA[Internal error. To see this error please display the PHP errors.]]></message></error></errors></prestashop> nel log di apache non c'è scritto nulla... Edited September 8, 2015 by davidemaglio (see edit history) Link to comment Share on other sites More sharing options...
davidemaglio Posted September 8, 2015 Share Posted September 8, 2015 Come non detto, è andato. O almeno sulla modifica, devo capire ora come inviarla se non vi sia nessuna immagine. Link to comment Share on other sites More sharing options...
AlbertoV Posted September 8, 2015 Share Posted September 8, 2015 Per vedere l'errore devi modificare il parametro: define('_PS_MODE_DEV_', false); in define('_PS_MODE_DEV_', true); all'interno del file defines.inc.php Link to comment Share on other sites More sharing options...
davidemaglio Posted September 8, 2015 Share Posted September 8, 2015 Per vedere l'errore devi modificare il parametro: define('_PS_MODE_DEV_', false); in define('_PS_MODE_DEV_', true); all'interno del file defines.inc.php Sì, quello c'era. Ma la risposta era comunque quella. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now