创建媒体 - Magento API (Soap)
我的 PHP 脚本有一点问题。这个使用 Magento API 并尝试为产品创建媒体。
$imageData = array(
'file' => array(
'name' => 'myimage.jpg',
'content' => base64_encode(file_get_contents($product_image_url)),
'mime' => 'image/jpeg'
),
'label' => 'Product Image #4',
'position' => 1,
'types' => array('small_image','image','thumbnail'),
//'types' => array('image'),
'exclude' => 0
);
$image_create = $client->call($sessID, 'product_media.create', array($product_id, $imageData));
$client->call($sessID, 'product_media.update', array($product_id, $image_create));
当我使用小图像(大约 10ko,100x100 像素)运行此脚本时,一切正常,但是当我尝试使用大图像(140k,500x500 像素)肥皂时返回此错误:
SoapFault exception: [HTTP] Internal Server Error in /var/www/vhosts/domain.com/httpdocs/test_update.php:46 Stack trace: #0 [internal function]: SoapClient->__doRequest('__call('call', Array) #2 /var/www/vhosts/domain.com/httpdocs/test_update.php(46): SoapClient->call('068bd88e8f56261...', 'product_media.c...', Array) #3 {main}
我的想法是长度,当它是base64_encode(file_get_contents($product_image_url)) 的大图像太大,然后 Soap 失败。
也许是 Apache 或 PHP conf 文件?
桑特雷夫。
I have a little problem with my PHP script. This one use the Magento API and try to create a media for a product.
$imageData = array(
'file' => array(
'name' => 'myimage.jpg',
'content' => base64_encode(file_get_contents($product_image_url)),
'mime' => 'image/jpeg'
),
'label' => 'Product Image #4',
'position' => 1,
'types' => array('small_image','image','thumbnail'),
//'types' => array('image'),
'exclude' => 0
);
$image_create = $client->call($sessID, 'product_media.create', array($product_id, $imageData));
$client->call($sessID, 'product_media.update', array($product_id, $image_create));
When I run this script with a little image (about 10ko, 100x100 pixels), everything works fine, but when I try with a large image (140k, 500x500 pixels) soap return this error :
SoapFault exception: [HTTP] Internal Server Error in /var/www/vhosts/domain.com/httpdocs/test_update.php:46 Stack trace: #0 [internal function]: SoapClient->__doRequest('__call('call', Array) #2 /var/www/vhosts/domain.com/httpdocs/test_update.php(46): SoapClient->call('068bd88e8f56261...', 'product_media.c...', Array) #3 {main}
My idea is that the length, when it's a large image, of base64_encode(file_get_contents($product_image_url)) is too big and then Soap fail.
Maybe Apache or PHP conf file?
Santerref.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,很可能是 PHP 或 Apache 导致了此错误。检查您的 Apache error_log 是否有任何线索。一些可能的 PHP 配置 选项:
Yes, it's very likely that PHP or Apache is causing this error. Check your Apache error_log for any clues. Some possible PHP configuration options: