H
H
Harveyy2021-11-24 14:18:35
PHP
Harveyy, 2021-11-24 14:18:35

How to upload images to VK Market via PHP SDK?

I'm trying to upload images via the VK API PHP SDK. To get access token I use Authorization Code Flow. I am requesting with permissions VK\OAuth\Scopes\VKOAuthUserScope::MARKET, VK\OAuth\Scopes\VKOAuthUserScope::PHOTOS.
The token can be received, everything is fine.
It is also possible to get the upload_url for uploading images via the $vk->photos()->getMarketUploadServer() method.

But when I move on, strange errors appear.
The $vk->getRequest()->upload( $uploadServer['upload_url'], $img_title, $img_path ) method returns a PHP error:
Uncaught TypeError: Argument 1 passed to VK\Client\VKApiError::__construct() must be of the type array, string given, called in /vendor/vkcom/vk-php-sdk/src/VK/Client/VKApiError.php: 27. Some internal error in the SDK, with which it is not clear what to do.

I also tried using CURL directly. Returns an error: {"error":"ERR_UPLOAD_BAD_IMAGE_SIZE: market photo min size 400x400","bwact":"do_add","server":535136,"_sig":"e4c41105c5b06d61aa2f3d7cc2cf26f2"}
Although the image size is larger than 400x400.
Has anyone experienced this? What to do? Help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question