代码之家  ›  专栏  ›  技术社区  ›  Gîanfranco P.

VK(vkontakte)API错误:尝试发布到墙时拒绝访问

  •  0
  • Gîanfranco P.  · 技术社区  · 8 年前

    我通过使用以下URL授权用户来获得令牌:

    const fetch = require('node-fetch');
    
    const VK_CLIENT_ID = '1231231';
    
    const photos = 4;
    const wall = 8192;
    const offline = 65536;
    const scope = offline + wall + photos;
    
    const URL = `https://oauth.vk.com/authorize?client_id=${VK_CLIENT_ID}&display=popup&redirect_uri=http://example.com/auth/vk&scope=${scope}&response_type=token&v=5.78`;
    
    const accessToken = '...';
    const ownerID = '212121212';
    
    fetch(
      `https://api.vk.com/method/wall.post?v=5.78&message=test_api&owner_id=${ownerID}&access_token=${accessToken}`
    )
      .then(res => res.text())
      .then(body => console.log(body));
    

    {
      error: {
        error_code: 15,
        error_msg: "Access denied: no access to call this method",
        request_params: [
          { key: "oauth", value: "1" },
          { key: "method", value: "wall.post" },
          { key: "v", value: "5.78" },
          { key: "message", value: "test_api" },
          { key: "owner_id", value: "184591202" }
        ]
      }
    }
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Gîanfranco P.    8 年前

    我找到原因了。无法使用此API方法。您需要一个独立的VK应用程序(用于桌面或移动应用程序),然后用户需要批准发布到墙上。

    VK API, access denied for post on wall of a community, fail WALL Permissions