Search the Community
Showing results for tags 'Curl'.
-
Buenos dias, He instalado el módulo de Paypal (última versión) en PrestaShop 1.7.6.1 y en botón de "comprobar requisitos" indica que "La extensión cURL de PHP debe estar activada en el servidor." He verificado mediante el archivo info.php que está activado. Después de buscar información no he encontrado respuesta que me sirva de ayuda. ¿Algien a tenido el mismo problema y lo ha solucionado?
-
extension cURL PHP
moi111 posted a topic in Utilisation de PrestaShop : configuration et difficultés
Bonjour, j'ai ce problème : L'extension cURL PHP doit être activée sur votre serveur.. Comment l'activer ? -
Bonjour, J'essaye de consommer le service web prestashop avec un logiciel type Curl. Le GET marche bien comme suis: GET ("https://domaine/api/customers/1?output_format=JSON", authenticate("FJ1T7FE6JVT8PHME5SK8D9A34RFDGT56","")) Par contre le POST ne marche pas: POST ("https://domaine/api/customers/1", authenticate("FJ1T7FE6JVT8PHME5SK8D9A34RFDGT56",""), body = body1, content_type("text/xml")) Le message d'erreur recu est le suivant: Response [https://domaine/api/customers/1] Date: 2019-08-07 14:01 Status: 400 Content-Type: text/xml;charset=utf-8 Size: 232 B <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[41]]></code> <message><![CDATA[parameter "passwd" required]]></message> </error> </errors> </prestashop> La version de prestashop est 1.7.5.1 est tous les autres methodes d'authetication marchent pas (i.e. en incluant la ws_key dans l'url) Merci!
- 4 replies
-
- curl
- authentication
-
(and 1 more)
Tagged with:
-
Bonjour à tous ! Je me lance dans un petit chantier de liaison de mon prestashop à une plateforme de transport. Après échange avec eux, ils m'ont transmis des lignes de code avec des requêtes cURL à inclure à un fichier PHP. Le but est : "Pouvoir commander un coursier directement depuis un site internet, un intranet ou toute autre application d’un partenaire. L’API permet de spécifier l’adresse d’enlèvement, de destination, le colisage, le niveau de prestation et une référence client." Le but est donc de récupérer les informations lors d'une commande pour envoyer les informations de celle-ci à une plateforme. Je cherche à comprendre, faut-t-il juste créer un nouveau fichier PHP pour y inclure le code ? Le placer dans un fichier existant ? Créer un module dans lequel sera placé ce fichier PHP ? Les informations à fournir sont notamment le nom, prénom, adresse, colisage... Ou se situe le code de ses informations (variables en fonction de la commande et du client du coup) afin que je puisse les lier à ma requête ? Pour un exemple, dans le code il y a : 'Street' => 'Rue de la Pompe', Il va bien falloir que je remplace "rue de la pompe" par "ce que va rentrer le client dans le formulaire à la case 'rue' Je vous met la doc API afin que vous puissiez comprendre, Merci pour votre réponse, a plus tard ! Nayan Api coursierfr - commande v1 3 (1) (1).pdf
-
I'm trying to set the file directories to another location entirely like using the Amazon S3. Getting the images is easy as I can set the url in the config files. But when it comes to uploading images, it's kinda difficult as I dont know what is the best way to do it. I have an API that will handle the GET, POST, DELETE of files. How and WHERE to call the API especially for POSTing files (upload) in PS is my problem. Is there a core class that handles all file/images/themes uploads/downloads that I can update and it will reflect on all file upload cases? Please help!
-
Bonjour, Je suis actuellement sous prestashop 1.6.1.3 en local (sous wamp). Mon but est d'envoyer les informations relatives aux commandes, clients et produits de ma boutique presta vers un crm extérieur. Pour cela j'ai fais un hookActionValidateOrder dans lequel je me sers de curl pour communiquer au crm. seulement je n'arrive même pas à avoir la connexion au crm. j'ai activé curl dans le php.ini Cordialement
-
Bonjour, Je suis actuellement sous prestashop 1.6.1.3 en local (sous wamp). Mon but est d'envoyer les informations relatives aux commandes, clients et produits de ma boutique presta vers un crm extérieur. Pour cela j'ai fais un hookActionValidateOrder dans lequel je me sers de curl pour communiquer au crm. seulement je n'arrive même pas à avoir la connexion au crm. j'ai activé curl dans le php.ini Cordialement
-
Buongiorno a tutti, ho installato prestashop in un ambiente Easyphp Windows (Devserver) e durante l'installazione mi segnala che il modulo cURL non è installato Ho provveduto a decommentare l'estensione nel modulo php.ini Ho provveduto a copiare i seguenti files: libeay32.dll e ssleay32.dll nella directory Windows\Systems32 Che altro tentare ? Grazie a tutti
-
Hola! Primero que todo, llevo un tiempo con prestashop (algo de 6 meses) y desde que he trabajado con este e-commerce ha sido difícil adaptarse de un tiempo a este ... Bueno la cosa que el sitio ya está funcionando, hay harto tráfico pero! paso que de un momento a otro dejó de funcionar el catálogo de módulos, además de no poder ver los módulos instalados, ya que trata de conectarse al api de prestashop antes de mostrar lo instalado. Adjunto dos imágenes donde se aprecia el problema, más las pruebas directamente del servidor por el error de "no se puede resolver la direccion bla bla bla" No se si alguno de ustedes puede ayudarme con este problema. Atentamente, GSV.
- 1 reply
-
- catalog
- connection
-
(and 2 more)
Tagged with:
-
Hello, I'm currently interfacing my Erp to Prestashop 1.7.2.4 by the web service and the curl.exe tool. I write the xml datas in a file and I use curl to send and receive informations. I already send categories, products, and stocks ... ouff ! Now I'm trying to send pictures like this : curl.exe -X POST --header "Content-Type: image/jpeg" --data-binary @c:\gi\fabel\images\tri0000000029.jpg --user XXXXXXXXXXXXXXXXXX: www.MySite.com/shop/api/images/products/23 -o c:\gi\fabel\presta\111800002409img_2gi.xml but I always an error 66 ! Can you tell me if the method is good ? or must I put the image inside a XML file ? a sample ? Thank for your help. JC
-
hey there, I came across a pretty strange bug with the webservice library and curl and wonder if that has happened to anyone else here before or if anyone has a reasonable explanation. I developed a module that uses the webservice to gather product data. On several test systems everything worked fine. When deployed to the productive system, the webservice stopped delivering results when the request included a filter. After several hours of debugging I was able to trace the bug into the webservice library: when using a filter in the webservice call, the url which is used in the curl request is as follows: shop.xy/api/products?filter[name]=%[e]%&display=full => empty xml If we open that URL within a browser or use the webservice library on our productive system we get an empty xml sheet as result. It works fine on the test system. To solve the problem and get the requested data we simply have to replace the "&" in the URL with "&" but only if that is in front of the display parameter. shop.xy/api/products?filter[name]=%[e]%&display=full => correct data If we replace every occurence of "&", for example when we have added the "limit" Parameter (shop.xy/api/products?filter[name]=%[e]%&display=full&limit=5 => empty xml) then the script again stops working. The solution: Adding the following line into line 109 makes everything work as it should. $url = str_replace("&display", "&display", $url); We have included the library into our module which means that the presta system itself is still updateable, but still this is just a workaround and against developing standards. Are there any recommendations or explanations for this kind of behaviour? Productive system is running php 7.0.27 with curl 7.38.0. We used the most up-to-date version of the library and I'll attach my new version of it. Thank you! PSWebServiceLibrary.php
-
- webservice
- rest
-
(and 2 more)
Tagged with:
-
Dear experienced developers, Overview: I am consuming an API to send an order out to carrier vendor upon order creation in Prestashop 1.6.1.14. When a customer purchase an item, chose a specific carrier and successfully make necessary payment, it will send out the order to carrier vendor. What I have created: 1) A custom module with hookdisplayAdminOrder - I am using this to display a button so I can print Shipping and Return labels to attach to item physically. 2) Custom module has been created with an option to set configuration fields via backoffice. I will be using the fields to set my Curl options. 3) Curl token has been generated and cached in proper, for usage to send out orders Issues: 1) I have read online that there is a hook called actionValidateOrder, it is currently triggering upon creation of an order. Am I using the right hook for as I should also check on validated payment? 2) I would like to understand how to pull/retrieve the data for new orders? I will use these data to send out the order to shipping vendor via API such as Customer name, Address etc. Thank you for time and guidance.
-
Hello, I'm trying to upload an image to a folder called uploads in my module's root. I have been able to accomplish this with the shop installed on my machine but I cannot upload the desired image to the remote shop. Here is my code: connector.php, to use curl to send the image to the upload.php file: require_once(dirname(__FILE__).'../../../config/config.inc.php'); require_once(dirname(__FILE__).'../../../init.php'); if (isset($_FILES['userfile']['tmp_name'])) { $ch = curl_init(); $cfile = new CURLFile($_FILES['userfile']['tmp_name'],$_FILES['userfile']['type'],$_FILES['userfile']['name']); $data = array('image'=>$cfile); curl_setopt($ch,CURLOPT_URL,_PS_BASE_URL_."/modules/customizeproducts/upload.php"); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); $resp = curl_exec($ch); if($resp == true){ echo "success"; } else{ echo curl_error($ch); } } the upload.php file: if (isset($_FILES['image']['tmp_name'])) { error_reporting(E_ALL); $uploaddir = 'uploads/'; $uploadfile = $uploaddir . basename($_FILES['image']['name']); if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) { $data = array($uploadfile,$uploaddir); echo json_encode($data); } else { echo "Possible file upload attack!\n"; print_r($_FILES); } } This is the console.log "Possible file upload attack! Array ( [image] => Array ( [name] => shoex.jpeg [type] => image/jpeg [tmp_name] => /tmp/phpkwpWFu [error] => 0 => 8373 ) ) " I'm a newbie to php and curl Help would be greatly appreciated!
-
Hi everyone. I'm new in this forums, thanks for reading. I've tried the prestashop webservice using the php example script located in the documentation and i've read it all. It's really easy and works great. But now i'm trying to use the webservice via cURL command line client. i managed to make GET, PUT, and DELETE requests but when i try to make a POST request i get a HTTP/1.1 500 Internal Server Error. This is the command i launch: curl -v -X POST -H "Content-type:text/xml" --data-urlencode @cnew.xml "http://JXDLSL4MTV0GLFFNIMC4H35L4DV93IYP:@192.168.1.3/prestashop/api/customers/" I use -v for verbose. I get this: * About to connect() to 192.168.1.3 port 80 (#0) * Trying 192.168.1.3... connected * Connected to 192.168.1.3 (192.168.1.3) port 80 (#0) * Server auth using Basic with user 'JXDLSL4MTV0GLFFNIMC4H35L4DV93IYP' > POST /prestashop/api/customers/ HTTP/1.1 > Authorization: Basic SlhETFNMNE1UVjBHTEZGTklNQzRIMzVMNERWOTNJWVA6 > User-Agent: curl/7.21.7 (i386-pc-win32) libcurl/7.21.7 OpenSSL/0.9.8r zlib/1.2 .5 libidn/1.18 libssh2/1.2.8 librtmp/2.3 > Host: 192.168.1.3 > Accept: */* > Content-type: text/xml > Content-Length: 989 > < HTTP/1.1 500 Internal Server Error < Date: Fri, 22 Jun 2012 08:59:59 GMT < Server: Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl /2.0.4 Perl/v5.10.1 < X-Powered-By: PrestaShop Webservice < Access-Time: 1340355599 < PSWS-Version: 1.4.7.0 < Execution-Time: 0.016 < Content-Length: 241 < Connection: close < Content-Type: text/xml;charset=utf-8 < <?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 error s.]]></message> </error> </errors> </prestashop> * Closing connection #0 The content of cnew.xml file is a new customer: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <customer> <id></id> <id_default_group></id_default_group> <newsletter_date_add></newsletter_date_add> <ip_registration_newsletter></ip_registration_newsletter> <last_passwd_gen></last_passwd_gen> <secure_key></secure_key> <deleted></deleted> <passwd></passwd> <lastname>Ñoréz</lastname> <firstname>Trinitarió Fúlgencio</firstname> <email>[email protected]</email> <note></note> <id_gender></id_gender> <birthday></birthday> <newsletter></newsletter> <optin></optin> <active>1</active> <is_guest></is_guest> </customer> </prestashop> If I use --trace-ascii instead of -v: curl --trace-ascii err.txt -X POST -H "Content-type:text/xml" --data-urlencode @cnew.xml "http://JXDLSL4MTV0GLFFNIMC4H35L4DV93IYP:@192.168.1.3/prestashop/api/customers/" I get a err.txt file with more information. This is its content: == Info: About to connect() to 192.168.1.3 port 80 (#0) == Info: Trying 192.168.1.3... == Info: connected == Info: Connected to 192.168.1.3 (192.168.1.3) port 80 (#0) == Info: Server auth using Basic with user 'JXDLSL4MTV0GLFFNIMC4H35L4DV93IYP' => Send header, 308 bytes (0x134) 0000: POST /prestashop/api/customers/ HTTP/1.1 002a: Authorization: Basic SlhETFNMNE1UVjBHTEZGTklNQzRIMzVMNERWOTNJWVA 006a: 6 006d: User-Agent: curl/7.21.7 (i386-pc-win32) libcurl/7.21.7 OpenSSL/0 00ad: .9.8r zlib/1.2.5 libidn/1.18 libssh2/1.2.8 librtmp/2.3 00e5: Host: 192.168.1.3 00f8: Accept: */* 0105: Content-type: text/xml 011d: Content-Length: 989 0132: => Send data, 989 bytes (0x3dd) 0000: %3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0 0040: A%3Cprestashop%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F19 0080: 99%2Fxlink%22%3E%0A%3Ccustomer%3E%0A%09%3Cid%3E%3C%2Fid%3E%0A%09 00c0: %3Cid_default_group%3E%3C%2Fid_default_group%3E%0A%09%3Cnewslett 0100: er_date_add%3E%3C%2Fnewsletter_date_add%3E%0A%09%3Cip_registrati 0140: on_newsletter%3E%3C%2Fip_registration_newsletter%3E%0A%09%3Clast 0180: _passwd_gen%3E%3C%2Flast_passwd_gen%3E%0A%09%3Csecure_key%3E%3C% 01c0: 2Fsecure_key%3E%0A%09%3Cdeleted%3E%3C%2Fdeleted%3E%0A%09%3Cpassw 0200: d%3E%3C%2Fpasswd%3E%0A%09%3Clastname%3E%C3%91or%C3%A9z%3C%2Flast 0240: name%3E%0A%09%3Cfirstname%3ETrinitari%C3%B3%20F%C3%BAlgencio%3C% 0280: 2Ffirstname%3E%0A%09%3Cemail%3Etrini%40nor.ez%3C%2Femail%3E%0A%0 02c0: 9%3Cnote%3E%3C%2Fnote%3E%0A%09%3Cid_gender%3E%3C%2Fid_gender%3E% 0300: 0A%09%3Cbirthday%3E%3C%2Fbirthday%3E%0A%09%3Cnewsletter%3E%3C%2F 0340: newsletter%3E%0A%09%3Coptin%3E%3C%2Foptin%3E%0A%09%3Cactive%3E1% 0380: 3C%2Factive%3E%0A%09%3Cis_guest%3E%3C%2Fis_guest%3E%0A%3C%2Fcust 03c0: omer%3E%0A%3C%2Fprestashop%3E <= Recv header, 36 bytes (0x24) 0000: HTTP/1.1 500 Internal Server Error <= Recv header, 37 bytes (0x25) 0000: Date: Fri, 22 Jun 2012 08:32:26 GMT <= Recv header, 99 bytes (0x63) 0000: Server: Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/ 0040: 5.3.8 mod_perl/2.0.4 Perl/v5.10.1 <= Recv header, 37 bytes (0x25) 0000: X-Powered-By: PrestaShop Webservice <= Recv header, 25 bytes (0x19) 0000: Access-Time: 1340353946 <= Recv header, 23 bytes (0x17) 0000: PSWS-Version: 1.4.7.0 <= Recv header, 23 bytes (0x17) 0000: Execution-Time: 0.015 <= Recv header, 21 bytes (0x15) 0000: Content-Length: 241 <= Recv header, 19 bytes (0x13) 0000: Connection: close <= Recv header, 38 bytes (0x26) 0000: Content-Type: text/xml;charset=utf-8 <= Recv header, 2 bytes (0x2) 0000: <= Recv data, 241 bytes (0xf1) 0000: <?xml version="1.0" encoding="UTF-8"?>.<prestashop xmlns:xlink=" 0040: http://www.w3.org/1999/xlink">.<errors>.<error>.<message><![CDAT 0080: A[internal error. To see this error please display the PHP error 00c0: s.]]></message>.</error>.</errors>.</prestashop>. == Info: Closing connection #0 I've tried several "-H" options (headers) like: -H "Content-type:text/xml" and -H "Content-type:application/x-www-form-urlencoded" but I always get HTTP/1.1 500 Internal Server Error Can anybody help me PLEASE? Thanks in advance!!! -- Pamela Curts
- 8 replies
-
- webservice
- http
- (and 8 more)
-
Hello, I am currently trying to set up the WebService on my shop currently "hosted" on my localhost. I am following the Web service tutorial on the Prestashop documentation and I have issues with the Chapter 3 - First steps - Accessing the web service and listing customers. As indicated in the documentation I have : Enabled cURL from the good PHP.ini (used by PHP) Downloaded the WebServiceLibrary script at the root of my shop Created my own script at the root of the shop and called the WebService as follow : try { $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); //$xml = $webService->get(array('resource' => 'carts')); $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/carts?schema=blank')); } catch (PrestaShopWebserviceException $e) { // Here we are dealing with errors $trace = $e->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error<br />'.$e->getMessage(); } However, when accessing the script from my browser, I get the following error : Fatal error: Maximum execution time of 30 seconds exceeded in ...\PSWebServiceLibrary.php on line 140 The line 140 of the scripts refers to call to the curl_exec function : $session = curl_init($url); //... curl_setopt_array($session, $curl_options); $response = curl_exec($session); When accessing the desired url from the browser itself, I get the response right away. I tried to change the options given to cURL according to what I found on the internet http://stackoverflow.com/questions/33733922/curl-takes-too-long-to-load http://stackoverflow.com/questions/22355739/php-curl-long-execution-time Here is information about my setup taken from the Prestashop admin panel and phpinfo() function : STORE INFORMATION PrestaShop version: 1.6.1.11 // I have also tested with Prestashop 1.7 Shop URL: http://localhost/projects/prestashop_1.6/ Current theme in use: default-bootstrap SERVER INFORMATION OS : Windows 10 Wamp Package : EasyPHP Server software version: Apache/2.4.7 (Win32) PHP/5.4.24 PHP version: 5.4.24 Memory limit: 1024M Max execution time: 30 CURL cURL support : enabled cURL Information : 7.30.0 The shop is totally clear, I just have installed prestashop and activated the webservice right after. Thanks in advance for your help
-
Hi. I'm having a strange problem. I'm using the webservice via direct cURL calls, because I had problems with the PSWebServiceLibrary doing stupid things and mainly just getting in the way (though I did briefly test this with the library as well, with the same error). I'm trying to add order_histories via the webservice to update the order status and history (as merely updating the order via the orders resource doesn't change the order history, and I'm not sure if it'll send the email to the customer either). Anyway, for some strange reason it does not work. Editing an existing order_histories with PUT request works, but as soon as I try to POST, I get this error: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <errors> <error> <code><![CDATA[127]]></code> <message><![CDATA[xml error : String could not be parsed as XML XML length : 0 Original XML : ]]></message> </error> </errors> </prestashop> The obvious problem is XML length: 0. As if I hadn't sent the XML at all. But the Content-Length of my outgoing request isn't 0, so the XML itself is definitely being sent in CURLOPT_POSTFIELDS. And the exact same function (except for the different CURLOPT_CUSTOMREQUEST setting, and of course adding the ID for PUT in the XML data) is sending the PUT request where the XML is recognized (if there's a problem with the XML I get an error as I should, but even then XML length is correct and the original XML is listed). So basically everything else being identical, PUT request works, POST doesn't. What on earth could cause this? I've been banging my head at this for hours, with no luck.
- 1 reply
-
- webservice
- POST
-
(and 1 more)
Tagged with:
-
Good day, dear friends! Trying to solve the problem for several weeks with the import of thousands of Microsoft Word documents at the REST API I have not found the section of virtual files (table ps_product_download). Also I was not able to save the form products through the curl, since I could not deal with the of tokens and session in the backoffice. Prestashop always done a redirect (302) to "sitename/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts" even the tokens and cookies have been right. Also I tried to login at AdminLogin controller (CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR) and after I send curl to AdminProducts Version prestashop 1.6. Please help with at least some of the functional implementation. presto.ru is a locale domain (DNS at my server) $url = 'http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2'; rtrim($fields_string, '&'); $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => true, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_FRESH_CONNECT => true, CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks CURLOPT_COOKIE => 'ee71a5687e53d260a86f630d713c16c7=8n%2FM156B1IFMl6JyKvURwD5W%2FjQfsSE1ut6vFMzjFZ4CMgl2ErVV9NRS1dMVhKFoK6UJEmBi6j2S6rTpq4BPc1DrsVZgNOe%2B3%2BcPcXpvr69ejoJVe7ss1WvzBp6kxqhSMyCu9KJ%2B6uWFgp%2F90dz1guFo6WfULIks3iq6e%2BFEgVe4OMBFsLL5M%2FTd2wmNkMVtexu1HjwvIKLVL%2BOXFLJ%2FJmMXQlh6OYIoioNrqnxR1P82WUb%2Ft%2FDuh34nF%2B2cJ%2FV7rIJhHdSvkDgSKC8MDaFwwRep5Lt7LDsMdu73W%2BqHpKikWlyCIcNTqHzMKCUpVli%2BwgDTuM8GbLGSloqfIz7NU1ckBg6ZfGv%2FKzsYFNAO6%2F8ygShS6MVymXGnY6pwJ3tgvC%2FyAFBoJ7R7RkgwurhnwWMltghwnevR1p3KET5CN5INKaXBAtx4Yk8HH0u1PieitrNKG63N7tv6bS9sk732FWJmEvJ2pP0%2F4a4dHpuMCUI%3D000361; __utma=176580068.1616360627.1413726914.1413726914.1413726914.1; __utmc=176580068; __utmz=176580068.1413726914.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); 2a0f1a0291a189ec406f99a4c735e244=8n%2FM156B1IFMl6JyKvURwBcyxX%2F1li63hWLXICHOdvPyRkKBkYtSOZTWRILsBTDNgxX0IjdA2ukBzBVWBI%2BqTx3mlyiNDgwTcju5U181L0BG8%2BMEB%2Fcf1hP6SCRbcCZzw3ngUqlg0K3Gbl7Asvw5HwWc5o0nKFkD0DCunsF5aumxBKW6laQKs1U24FCXliH1bfy2yGHK7euIWdIyMcpCyXh12b9Ez3f2X2Sm8aCu%2Fxc3iToLS%2BDZAW0phFflvvSLIYCGZsvNVRdvxpYWa0TtyXnoMcSWk8AuyD%2FD5N8eWZk%3D000210', ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; var_dump($header); array(29) { ["url"]=> string(100) "http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2" ["content_type"]=> string(24) "text/html; charset=utf-8" ["http_code"]=> int(302) ["header_size"]=> int(624) ["request_size"]=> int(131) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.074438) ["namelookup_time"]=> float(0.001165) ["connect_time"]=> float(0.001255) ["pretransfer_time"]=> float(0.001296) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(0) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.074392) ["redirect_time"]=> float(0) ["certinfo"]=> array(0) { } ["primary_ip"]=> string(12) "178.63.16.66" ["primary_port"]=> int(80) ["local_ip"]=> string(12) "178.63.16.66" ["local_port"]=> int(41922) ["redirect_url"]=> string(120) "http://presto.ru/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts" ["errno"]=> int(0) ["errmsg"]=> string(0) "" ["content"]=> string(624) "HTTP/1.1 302 Found Server: nginx/1.2.1 Date: Wed, 29 Oct 2014 12:02:43 GMT Content-Type: text/html; charset=utf-8 Content-Length: 0 Connection: keep-alive X-Powered-By: PHP/5.4.4-14+deb7u11 Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=0; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=presto.ru; httponly Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=wk19Blz4NWrpyLvhiOOx5fxYzWjLnFSqlL9gk7mlrNA%3D000019; expires=Tue, 18-Nov-2014 12:02:43 GMT; path=/; domain=presto.ru; httponly Location: index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts Vary: Accept-Encoding " }
-
Добрый день! Не могу найти в REST API раздела виртуальных/загружаемых файлов (из таблицы ps_product_download), чтобы импортировать туда скриптом свои (их несколько тысяч). Также не могу получить доступ к сохранению формы товара через curl к бэкофису из-за системы сессий, куки и токенов. Prestashop редиректит с 302 кодом на "sitename/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts", даже когда токены и куки взяты из моего браузера (в котором сессия исправна) непосредственно. Пытался также залогиниться через контроллер AdminLogin, используя CURLOPT_COOKIEFILE и CURLOPT_COOKIEJAR, а далее обратиться к AdminProducts. Версия prestashop 1.6. Буду очень рад помощи хоть с какой-нибудь реализацией того функционала, что мне нужен. Есть идея использовать код загрузки виртуального файла в prestashop и самому обработать (переместить, захешировав название) и вставить в базу, но не знаю получится ли без использования всего фреймворка. И как, в таком случае, подключить фреймворк к стороннему скрипту (наподобие того, как делается с Zend и Yii) тоже не знаю. presto.ru - локальный домен (DNS на моем сервере) $url = 'http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2'; rtrim($fields_string, '&'); $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => true, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects CURLOPT_FRESH_CONNECT => true, CURLOPT_SSL_VERIFYPEER => false, // Disabled SSL Cert checks CURLOPT_COOKIE => 'ee71a5687e53d260a86f630d713c16c7=8n%2FM156B1IFMl6JyKvURwD5W%2FjQfsSE1ut6vFMzjFZ4CMgl2ErVV9NRS1dMVhKFoK6UJEmBi6j2S6rTpq4BPc1DrsVZgNOe%2B3%2BcPcXpvr69ejoJVe7ss1WvzBp6kxqhSMyCu9KJ%2B6uWFgp%2F90dz1guFo6WfULIks3iq6e%2BFEgVe4OMBFsLL5M%2FTd2wmNkMVtexu1HjwvIKLVL%2BOXFLJ%2FJmMXQlh6OYIoioNrqnxR1P82WUb%2Ft%2FDuh34nF%2B2cJ%2FV7rIJhHdSvkDgSKC8MDaFwwRep5Lt7LDsMdu73W%2BqHpKikWlyCIcNTqHzMKCUpVli%2BwgDTuM8GbLGSloqfIz7NU1ckBg6ZfGv%2FKzsYFNAO6%2F8ygShS6MVymXGnY6pwJ3tgvC%2FyAFBoJ7R7RkgwurhnwWMltghwnevR1p3KET5CN5INKaXBAtx4Yk8HH0u1PieitrNKG63N7tv6bS9sk732FWJmEvJ2pP0%2F4a4dHpuMCUI%3D000361; __utma=176580068.1616360627.1413726914.1413726914.1413726914.1; __utmc=176580068; __utmz=176580068.1413726914.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); 2a0f1a0291a189ec406f99a4c735e244=8n%2FM156B1IFMl6JyKvURwBcyxX%2F1li63hWLXICHOdvPyRkKBkYtSOZTWRILsBTDNgxX0IjdA2ukBzBVWBI%2BqTx3mlyiNDgwTcju5U181L0BG8%2BMEB%2Fcf1hP6SCRbcCZzw3ngUqlg0K3Gbl7Asvw5HwWc5o0nKFkD0DCunsF5aumxBKW6laQKs1U24FCXliH1bfy2yGHK7euIWdIyMcpCyXh12b9Ez3f2X2Sm8aCu%2Fxc3iToLS%2BDZAW0phFflvvSLIYCGZsvNVRdvxpYWa0TtyXnoMcSWk8AuyD%2FD5N8eWZk%3D000210', ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; var_dump($header); array(29) { ["url"]=> string(100) "http://presto.ru/admin0401/index.php?controller=AdminProducts&token=59576455bbd31e4bf712ede77c05a6d2" ["content_type"]=> string(24) "text/html; charset=utf-8" ["http_code"]=> int(302) ["header_size"]=> int(624) ["request_size"]=> int(131) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.074438) ["namelookup_time"]=> float(0.001165) ["connect_time"]=> float(0.001255) ["pretransfer_time"]=> float(0.001296) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(0) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.074392) ["redirect_time"]=> float(0) ["certinfo"]=> array(0) { } ["primary_ip"]=> string(12) "178.63.16.66" ["primary_port"]=> int(80) ["local_ip"]=> string(12) "178.63.16.66" ["local_port"]=> int(41922) ["redirect_url"]=> string(120) "http://presto.ru/admin0401/index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts" ["errno"]=> int(0) ["errmsg"]=> string(0) "" ["content"]=> string(624) "HTTP/1.1 302 Found Server: nginx/1.2.1 Date: Wed, 29 Oct 2014 12:02:43 GMT Content-Type: text/html; charset=utf-8 Content-Length: 0 Connection: keep-alive X-Powered-By: PHP/5.4.4-14+deb7u11 Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=0; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=presto.ru; httponly Set-Cookie: 2a0f1a0291a189ec406f99a4c735e244=wk19Blz4NWrpyLvhiOOx5fxYzWjLnFSqlL9gk7mlrNA%3D000019; expires=Tue, 18-Nov-2014 12:02:43 GMT; path=/; domain=presto.ru; httponly Location: index.php?controller=AdminLogin&token=d7218c4a4f379d3b455e5fd45fccefc1&redirect=AdminProducts Vary: Accept-Encoding " }
-
Hi everyone! I'm newbie on Prestashop and I'm developing a project that connects a website with the prestashop backend but I've found some problems and I don't know if what I'm looking for is possible or not. We've a website with information of different commerces and some of them want to sell their items via Prestashop but without re login on Prestashop, directly from our website. These two projects have different databases and they are installed in different servers. So I need to do these tasks: - duplicate the users into Prestashop - add a button on our website that logs the users and redirects them to the prestashop backend I've seen the webservice of prestashop but it hasn't implemented the login option. I've read some post on these forum and on the Internet and they have resolved it using the curl function. So I've try it with a script like this: <?php // where I want to go $url = 'http://localhost/prestashop/admin9027/index.php?controller=AdminLogin'; // post params of the login form $post_params = array('email' => '[email protected]', 'passwd' => '12345678', 'stay_logged_in' => 1, 'submitLogin' => 1); //Create a curl object $ch = curl_init(); //Set the useragent curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); //Set the URL curl_setopt($ch, CURLOPT_URL, $url); //This is a POST query curl_setopt($ch, CURLOPT_POST, 1); //Set the post data curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params); //We want the content after the query curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Follow Location redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //curl_setopt($ch, CURLOPT_HEADER, 0); /* Set the cookie storing files Cookie files are necessary since we are logging and session data needs to be saved */ curl_setopt($ch, CURLOPT_COOKIESESSION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); //Execute the action to login $post_result = curl_exec($ch); $info = curl_getinfo($ch); curl_close ($ch); /* echo '<pre>'; print_r($info); echo '</pre>'; */ echo $post_result; // the url of the dashoboard, where the loginAdmin redirects the user // (that doesn't work for me) //header("Location: ".$info['url']); ?> It works parcially. The problem I've found is this - the script is on http://localhost/test/index.php - and prestashop is on http://localhost/prestashop/index.php After the redirect, the user seems to be logged correctly, but the content is showed under http://localhost/test/ and then all the menu options are wrong and fail. For that I try with: <?php curl_setopt($ch, CURLOPT_HEADER, 1); ... // $info['url'] contains the url to the dashboard, // where the login redirects after the validation header("Location: ".$info['url']); ?> What I'm doing wrong? Have someone do something similar? How do you solve it? I've spent a couple of days trying to solve it so I'll be grateful with any help. Thanks to everyone María
-
Web Service ( CULR ): le immagini non vengono caricate
matteo.enter posted a topic in Report sui Bug
Salve a tutti, ho preparato uno script per poter caricare le immagini sia sugli articoli sia sulle categorie ma le immagini non vengono caricate ne su gli uni ne sulle altre nonostante non mi restituisca nessun errore. Questo è lo script per gli articoli: <? require_once( './configurazioni/WS_conf.inc' ); require_once( './PSWebServiceLibrary.php' ); $ris='ER|Nessuna operazione'; $nome_file=$_GET['nf']; $tipo=$_GET['tp']; $idart=$_GET['id']; $url = PS_SHOP_PATH.'api/images/products/'.$idart; if (file_exists(PS_IMG_PATH.$nome_file)) { $image_path = PS_IMG_PATH.$nome_file; $data_img = array('image'=>"@".$image_path.";type=image/jpeg"); $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_URL, $url); if ($tipo=='U') curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPAUTH, 'CURLAUTH_BASIC'); curl_setopt($ch, CURLOPT_USERPWD, PS_WS_AUTH_KEY.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_img); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if(curl_exec($ch) === false) $ris = 'ER|'.curl_error($ch); else $ris='OK|'; curl_close($ch); //unlink(PS_FILE_PATH.$nome_file); } else $ris.='ER|Immagine non presente|'; echo $ris; ?> dove sbaglio?- 10 replies
-
- webservice
- curl
-
(and 1 more)
Tagged with:
-
Bonjour, je suis actuellement sur la dernière version de prestashop 1.6.x. J'ai créer un petit script qui permet d'importer de façon dynamique un csv (en l'occurence csv de produits). Toutefois, l'import d'images ne fonctionne pas. J'ai donc utilisé un script fournit par prestashop : $url = 'http://myprestashop.com/api/images/products/1'; $image_path = 'C:\\my_image.png'; $key = 'My web service key'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); //curl_setopt($ch, CURLOPT_PUT, true); // Un-commet to edit an image curl_setopt($ch, CURLOPT_USERPWD, $key.':'); curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => '@'.$image_path)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); Ce script permet d'insérer ou mettre à jour l'image d'un produit. MON PROBLÈME est le suivant, je tire mes images d'un site en ligne : www.siteEnLigne.com/images/mon_image.jpg et lorsque je met ce chemin dans la variable $image_path, je n'ai aucun résultat. Après quelques recherches je pense que prestashop doit avoir uniquement le chemin en répertoire et ne prend pas en compte, par conséquent, le chemin "nom de domaine". Des avis ? De l'aide ? Merci d'avance !
-
Hi everyone, i have two websites: 1 - a normal website which requires to login to browse it 2 - a shop (PrestaShop 1.5.6.0) at the moment everytime that someone registers on the website i automatically create the user in the shop with the same credentials. My goal now is start the session of both the websites at the same time or better every time that someone login into the the website should be automatically logged in also on the shop Any Idea or suggestion on how to do it? I was thinking about try with CURL Thanks for any help
-
How can i execute an url using curl from my module in prestashop 1.5.4.1 The sample url is https://abcd.com/shop/xyz?name=aaaaa&id=1
-
Hi everyone, I am using prestahop v.1.5.2 and last few days I am trying to make a curl login into backend (later must create a login to frontend) but with no success. I have a custom site with user login area and prestashop in subfolder of my site. I want to "merge" the users and create а script which must set the cookies for prestashop (I have already created the existing users in mysite on prestashop). I have created a script but doesn`t work, there is no cookie set from prestashop for the user. Where is the problem, is there any other solution of my idea. This is my script: <?php $login_url = 'path_to_site/shop/admin_test/login.php'; $email="user_mail"; $passwd="user_pass"; //$post_fields = 'passwd='.urlencode($passwd).'&email='.urlencode($email); $datatopost = array( 'password' => $passwd, 'email' => $email ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $login_url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); $info = curl_getinfo($ch); $returndata = curl_exec ($ch); curl_close($ch); ?>