【发布时间】:2020-07-27 16:19:02
【问题描述】:
我正在尝试通过 Prestashop API 添加/上传产品图片,但出现服务器错误 500。 代码有什么问题?还是服务器配置有问题?
PHP 脚本:
error_reporting(-1);
ini_set('display_errors', 'On');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://MY_AUTH_KEY@my-shop.com//api/images/products/24/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, 'MY_AUTH_KEY:');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' =>'@http://my-shop.com/img/my-shop-logo-1584646645.jpg;type=image/jpg'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);
print_r($curlinfo);
这导致 [http_code] => 500。没有错误或任何东西。我可以访问托管服务提供商的服务器错误日志,但里面什么都没有……
脚本基于 Prestashop 文档:https://devdocs.prestashop.com/1.7/development/webservice/tutorials/change_product_image/
【问题讨论】:
标签: php api web-services curl prestashop