harmon Posted August 3, 2013 Share Posted August 3, 2013 Hi Can the webservice be used to get image uls? Thanks 1 Link to comment Share on other sites More sharing options...
RogueWaveLimited Posted August 3, 2013 Share Posted August 3, 2013 Yes, you can. Link to comment Share on other sites More sharing options...
harmon Posted August 3, 2013 Author Share Posted August 3, 2013 Can you mention the class function that is used, and if the image url is the same one that is listed on the product page? Thanks! Link to comment Share on other sites More sharing options...
RogueWaveLimited Posted August 4, 2013 Share Posted August 4, 2013 You can go to advanced parameters > webservice, enable the service then click "add new". This will show you all the abilities of the web service. I don't know if the URL is the same or not. Link to comment Share on other sites More sharing options...
razaro Posted August 4, 2013 Share Posted August 4, 2013 Check http://doc.prestashop.com/display/PS15/Using+the+PrestaShop+Web+Service there is detailed example. For images you can see http://doc.prestashop.com/display/PS15/Chapter+9+-+Image+management But also you can get products $opt = array( 'resource' => 'products', 'display' => 'full' ); and then get image link from "id_default_image". Link to comment Share on other sites More sharing options...
vekia Posted August 4, 2013 Share Posted August 4, 2013 but if it will be external app? is there any possibility to return the image link? i don't think so Link to comment Share on other sites More sharing options...
webddr.net Posted November 2, 2013 Share Posted November 2, 2013 For external application I use additional file to get the image, let say api-img.php contain <?php IMAGE_API_KEY = 'ajshsuashah7ahs7asha7h'; // webservice key with permission get image only $url = PS_SHOP_PATH .'/api/images/products/'. $_GET['imgurl']; header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Content-type:'); // not sure why this work $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, IMAGE_API_KEY.':'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_exec($ch); curl_close($ch); and then call the image within external app/website like <img src="api-img.php?imgurl=<?php echo $resources->id .'/'. $resources->id_default_image; ?>" /> 1 Link to comment Share on other sites More sharing options...
An'im Fahmy Posted September 14, 2015 Share Posted September 14, 2015 For external application I use additional file to get the image, let say api-img.php contain <?php IMAGE_API_KEY = 'ajshsuashah7ahs7asha7h'; // webservice key with permission get image only $url = PS_SHOP_PATH .'/api/images/products/'. $_GET['imgurl']; header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('Content-type:'); // not sure why this work $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, IMAGE_API_KEY.':'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_exec($ch); curl_close($ch); and then call the image within external app/website like <img src="api-img.php?imgurl=<?php echo $resources->id .'/'. $resources->id_default_image; ?>" /> I will try this one Link to comment Share on other sites More sharing options...
hardyahir Posted May 11, 2017 Share Posted May 11, 2017 I will try this one is it working for you ? i tried but wont work. Link to comment Share on other sites More sharing options...
wladimiravila Posted June 23, 2017 Share Posted June 23, 2017 (edited) Hello in the root of your project create a file called get-image.php in get-image.php put this code <?php header("Content-Type: image/jpeg"); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past $url = $_GET['img-url']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, 'hereYourPrestashopUserToUseWS' . ':'); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.1 Safari/537.11'); $res = curl_exec($ch); $rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch) ; echo $res; ?> in your another php file use the next code, downloading the library from here https://github.com/PrestaShop/PrestaShop-webservice-lib <?php $separator=DIRECTORY_SEPARATOR; require_once(ABSPATH . $separator. 'prestashop' .$separator.'PSWebServiceLibrary.php'); $ws = new PrestaShopWebservice("http:www.web.com", "hereYourPrestashopUserToUseWS", FALSE); /** * products data */ $opt = array( 'resource' => 'products', 'display' => '[id, id_default_image, name,link_rewrite]', 'limit' => '30' ); $xml = $ws->get($opt); $products = $xml->products->product; foreach ($products as $value): $imageObject = $value->id_default_image; $productId = $value->id; $productImage = $imageObject->attributes('xlink', true)->href; ?> <a href="<?php echo $url; ?>" target="_blank" > <img src="/get-image.php?img-url=<?php echo $productImage ?>" /></a> <?php endforeach; ?> Edited June 23, 2017 by wladimiravila (see edit history) Link to comment Share on other sites More sharing options...
hardyahir Posted June 23, 2017 Share Posted June 23, 2017 Hello in the root of your project create a file called get-image.php in get-image.php put this code hello, thank you for your valuable reply, but i already done all of my web services working which require to run android apps likewise any other eCommerce. Thanks Hardy Link to comment Share on other sites More sharing options...
Recommended Posts