简体   繁体   English

创建媒体-Magento API(肥皂)

[英]Create media - Magento API (Soap)

I have a little problem with my PHP script. 我的PHP脚本有一些问题。 This one use the Magento API and try to create a media for a product. 这个使用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));

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 : 当我使用少量图像(大约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}

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. 我的想法是,当它是大图像时,base64_encode(file_get_contents($ product_image_url))的长度太大,然后Soap失败。

Maybe Apache or PHP conf file? 也许Apache或PHP conf文件?

Santerref. Santerref。

Yes, it's very likely that PHP or Apache is causing this error. 是的,很可能是PHP或Apache导致了此错误。 Check your Apache error_log for any clues. 检查您的Apache error_log是否有任何线索。 Some possible PHP configuration options: 一些可能的PHP配置选项:

  • max_execution_time max_execution_time
  • memory_limit memory_limit
  • post_max_size post_max_size
  • upload_max_filesize upload_max_filesize

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM