如何使用Web服务prestashop删除图像

时间:2016-04-05 08:45:10

标签: php web-services prestashop-1.6

大家喜欢标题说我不知道​​如何删除图片。我可以添加和更新它们,但我找不到删除它们的方法。

这是我用来更新和添加图片的代码:

IEnumerable<string> personTexts = listOfPersons
    .Select(p => String.Join(",", p.ReferenceNumber, p.FirstName, p.Surname, ...));
string joined = String.Join(Environment.NewLine, personTexts);

任何帮助将不胜感激。

问候

2 个答案:

答案 0 :(得分:1)

试试这个:

$url = "http://192.168.1.124/prestashop/api/images/products/" . $idProduct . "/".$idImage."?ps_method=DELETE";

答案 1 :(得分:0)

我在Prestashop webservice Library中找到了删除对象的示例。 希望它能帮到你:

// Here we define constants /!\ You need to replace this parameters
define('DEBUG', true);
define('PS_SHOP_PATH', 'http://www.myshop.com/');
define('PS_WS_AUTH_KEY', 'ZQ88PRJX5VWQHCWE4EE7SQ7HPNX00RAJ');
require_once('./PSWebServiceLibrary.php');
if (isset($_GET['DeleteID']))
{
    //Deletion
    echo '<h1>Customers Deletion</h1><br>';
    // We set a link to go back to list
    echo '<a href="?">Return to the list</a>';
    try
    {
        $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
        // Call for a deletion, we specify the resource name and the id of the resource in order to delete the item
        $webService->delete(array('resource' => 'customers', 'id' => intval($_GET['DeleteID'])));
        // If there's an error we throw an exception
        echo 'Successfully deleted !<meta http-equiv="refresh" content="5"/>';
    }
    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();
    }
}
else
{
    // Else get customers list

}

来源:Prestashop webservice examples