开发者

Create media - Magento API (Soap)

开发者 https://www.devze.com 2023-04-10 04:13 出处:网络
I have a little problem with my PHP script. This one use the Magento API and try to create a media for a product.

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...'开发者_JAVA技巧, 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.


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:

  • max_execution_time
  • memory_limit
  • post_max_size
  • upload_max_filesize
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号