VK API Error 15 & 100 when posting photos to community wall via WordPress: "Access denied" and "No photo given" when using group token

1 day ago 1
ARTICLE AD BOX

I'm developing a WordPress plugin (lakend-crossposter.php) that automatically publishes blog posts to a VK community wall. I'm using the official PHP SDK (vkcom/vk-php-sdk). I'm facing an issue with image uploads: the post is published, but without the attached photo. The logs show two VK API errors:

Access denied: no access to call this method. It cannot be called with current scopes. (Code: 15) One of the parameters specified was missing or invalid: Violated: link_photo_sizing_rule. No photo given (Code: 100)

Context & Architecture:

WordPress Plugin: Uses standard hooks (e.g., publish_post) to trigger the posting. VK API Version: 5.199 Tokens: group_token: Community token (intended for all API calls, including wall.post). user_token: User token (was planned for photo uploads but is currently unused in the upload logic). Goal: The plugin attempts to upload the post's featured image and attach it to the wall post.

Code Snippets (Simplified):

Here is how the photo upload and post sending are handled in the CPA_VKontakte class:

1. Initialization and Token Check (__construct):

public function __construct() { $options = get_option('cpa_settings'); $this->group_token = $options['vk_group_token'] ?? ''; $this->group_id = $options['vk_group_id'] ?? ''; // user_token is loaded but not used for photos error_log('CPA VK Construct: group_token ' . (!empty($this->group_token) ? '✅ found' : '❌ missing')); }

2. Main Sending Method (send_post):

public function send_post($post, $is_anniversary = false) { // ... $params = [ 'owner_id' => -intval($this->group_id), 'from_group' => 1, 'message' => $message, 'v' => $this->api_version ]; // Attempt to upload photos (uses group_token) $attachments = $this->upload_post_attachments($post->ID); if (!empty($attachments)) { $params['attachments'] = implode(',', $attachments); } else { // If no photo, add the link as an attachment $params['attachments'] = get_permalink($post); } // Send the post using group_token $response = $this->vk->wall()->post($this->group_token, $params); // ... }

3. Photo Upload Method (upload_post_attachments):

private function upload_post_attachments($post_id) { // ... // ⚠️ USING ONLY GROUP TOKEN FOR PHOTO UPLOAD if (empty($this->group_token)) { /* ... */ } // 1. Get upload server (via group_token) $upload_server = $this->vk->photos()->getWallUploadServer($this->group_token, [ 'group_id' => intval($this->group_id) ]); // 2. Download and upload file to VK server $temp_file = $this->download_image($photo_url); $upload_response = $this->upload_file_to_vk($upload_server['upload_url'], $temp_file); // 3. Save photo to group wall (also via group_token) $save_response = $this->vk->photos()->saveWallPhoto($this->group_token, [ 'group_id' => intval($this->group_id), 'photo' => $upload_response['photo'], 'server' => $upload_response['server'], 'hash' => $upload_response['hash'] ]); // ... }

Logs (from the question):

[22-Feb-2026 09:57:41 UTC] CPA VK Construct: group_token ✅ found [22-Feb-2026 09:57:41 UTC] CPA VK Construct: group_id #0000000 [22-Feb-2026 09:57:41 UTC] CPA VK Construct: VK API client initialized [22-Feb-2026 09:57:41 UTC] CPA VK (Post ID: 302): Photo upload failed: Access denied: no access to call this method. It cannot be called with current scopes. (Code: 15) [22-Feb-2026 09:57:41 UTC] CPA VK (Post ID: 302) [DEBUG]: Sending post to VK... [22-Feb-2026 09:57:41 UTC] CPA VK (Post ID: 302): VK API Error: One of the parameters specified was missing or invalid: Violated: link_photo_sizing_rule. No photo given (Code: 100)

The Question:

The Code: 15 error occurs during the getWallUploadServer or saveWallPhoto step (the "Photo upload failed" log confirms this). I am using the group token for all calls, including the photo upload process.

Why does the group token, which successfully works for wall.post (there are no errors for that call in the logs), lack the necessary permissions (scopes) to call photos.getWallUploadServer and photos.saveWallPhoto? VK's documentation states that uploading a photo to a community wall requires the photos and wall permissions, and a group token or a user token with editor rights. The group token was generated in the community settings with the photos and wall checkboxes selected. Is this insufficient? Do I absolutely need to use the user token (user_token) for the upload steps (getting the server and saving), or is the problem elsewhere (e.g., the permissions of the VK ID app itself)?

Thank you for your help! I have attached the full code of the plugin classes for context.

Read Entire Article