vk
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCall the VK API with . The token is injected as
and is passed in the header. Every VK API call also
requires the (API version) query parameter — use . Base URL:
.
curl + jq$VK_ACCESS_TOKENAuthorization: Bearervv=5.199https://api.vk.com/method/<method>VK always returns HTTP 200; success is and failure is
— always check for
and show verbatim. Common codes: = auth failed (token wrong or
revoked → user must re-connect the VK connector), = access to adding post
denied (the token lacks the right — a community access key with is
required), / = access denied to that owner.
{"response": ...}{"error":{"error_code":<n>,"error_msg":"<detail>"}}.errorerror_msg5214wallwall15203使用调用VK API。令牌以的形式注入,并通过头传递。每一次VK API调用都需要(API版本)查询参数——请使用。基础URL为:。
curl + jq$VK_ACCESS_TOKENAuthorization: Bearervv=5.199https://api.vk.com/method/<method>VK始终返回HTTP 200状态码;成功时返回,失败时返回——务必检查字段,并原样显示内容。常见错误码: = 认证失败(令牌错误或已撤销 → 用户必须重新连接VK连接器), = 发布帖子权限被拒绝(令牌缺少权限 —— 需要带有权限的社区访问密钥),/ = 对该所有者的访问被拒绝。
{"response": ...}{"error":{"error_code":<n>,"error_msg":"<detail>"}}.errorerror_msg5214wallwall15203Step 1 — identify who you can post as
步骤1 — 确定发帖身份
A community access key posts on the community wall: must be the
negative community id and you pass . Resolve the community id
from the token:
owner_idfrom_group=1bash
curl -sS "https://api.vk.com/method/groups.getById?v=5.199" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
| jq '.response, .error'Take the group (e.g. ) → is . (For a personal
user token, is your positive user id from , and you omit
.)
id123456owner_id-123456owner_idusers.getfrom_group使用社区访问密钥将发布到社区墙:必须为负数形式的社区ID,并且需要传递参数。通过令牌解析社区ID:
owner_idfrom_group=1bash
curl -sS "https://api.vk.com/method/groups.getById?v=5.199" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
| jq '.response, .error'获取群组(例如)→ 即为。(如果是个人用户令牌,是通过获取的正数用户ID,并且不需要传递参数。)
id123456owner_id-123456owner_idusers.getfrom_groupPost to the wall
发布帖子到墙
Confirm the message text with the user before posting. The post must have
text and/or attachments.
bash
OWNER_ID="-123456" # negative = community; from_group=1 posts as the community
MSG="Пример поста через VK API. #ai"
curl -sS -G "https://api.vk.com/method/wall.post" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
--data-urlencode "v=5.199" \
--data-urlencode "owner_id=$OWNER_ID" \
--data-urlencode "from_group=1" \
--data-urlencode "message=$MSG" \
| jq '.response, .error'Success returns . The public URL is
(e.g. ).
{"response":{"post_id":<id>}}https://vk.com/wall<OWNER_ID>_<post_id>https://vk.com/wall-123456_17- Hashtags () and plain URLs in
#tagare rendered/clickable natively — no facet/offset handling needed (unlike Bluesky).message - Attach media/links with (comma-separated), format
attachments(e.g.{type}{owner_id}_{media_id}) or a single external URL. Only one link may be attached; more than one link → error 222.photo-123456_789 - (Unix timestamp) schedules a deferred post.
publish_date - Always send Cyrillic via
messageso it isn't mangled.--data-urlencode
**发帖前请与用户确认消息文本。**帖子必须包含文本和/或附件。
bash
OWNER_ID="-123456" # 负数代表社区;from_group=1表示以社区身份发帖
MSG="Пример поста через VK API. #ai"
curl -sS -G "https://api.vk.com/method/wall.post" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
--data-urlencode "v=5.199" \
--data-urlencode "owner_id=$OWNER_ID" \
--data-urlencode "from_group=1" \
--data-urlencode "message=$MSG" \
| jq '.response, .error'成功时返回。公开URL为(例如)。
{"response":{"post_id":<id>}}https://vk.com/wall<OWNER_ID>_<post_id>https://vk.com/wall-123456_17- 消息中的话题标签()和普通URL会被原生渲染为可点击状态——无需处理facet/offset(与Bluesky不同)。
#tag - 使用参数(逗号分隔)添加媒体/链接,格式为
attachments(例如{type}{owner_id}_{media_id})或单个外部URL。仅允许添加一个链接;添加多个链接会返回错误码222。photo-123456_789 - (Unix时间戳)用于设置定时发布的帖子。
publish_date - 发送西里尔文消息时务必使用,避免乱码。
--data-urlencode
List my recent wall posts + engagement
列出我的近期墙帖及互动数据
bash
OWNER_ID="-123456"
curl -sS -G "https://api.vk.com/method/wall.get" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
--data-urlencode "v=5.199" \
--data-urlencode "owner_id=$OWNER_ID" \
--data-urlencode "count=20" \
| jq '.error, (.response.items[]? | {id,
text,
likes: .likes.count,
reposts: .reposts.count,
comments: .comments.count,
views: .views.count,
date})'countowner_ididhttps://vk.com/wall<owner_id>_<id>bash
OWNER_ID="-123456"
curl -sS -G "https://api.vk.com/method/wall.get" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
--data-urlencode "v=5.199" \
--data-urlencode "owner_id=$OWNER_ID" \
--data-urlencode "count=20" \
| jq '.error, (.response.items[]? | {id,
text,
likes: .likes.count,
reposts: .reposts.count,
comments: .comments.count,
views: .views.count,
date})'countowner_ididhttps://vk.com/wall<owner_id>_<id>Delete a post
删除帖子
bash
OWNER_ID="-123456"; POST_ID="17"
curl -sS -G "https://api.vk.com/method/wall.delete" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
--data-urlencode "v=5.199" \
--data-urlencode "owner_id=$OWNER_ID" \
--data-urlencode "post_id=$POST_ID" \
| jq '.response, .error'bash
OWNER_ID="-123456"; POST_ID="17"
curl -sS -G "https://api.vk.com/method/wall.delete" \
-H "Authorization: Bearer $VK_ACCESS_TOKEN" \
--data-urlencode "v=5.199" \
--data-urlencode "owner_id=$OWNER_ID" \
--data-urlencode "post_id=$POST_ID" \
| jq '.response, .error'Gotchas
注意事项
- is mandatory on every call — omitting it returns an error.
v - User tokens can't be freshly minted via OAuth (Implicit / Authorization
Code flows for user tokens were disabled 2024-06); use a community access
key (unlimited lifetime, created in the community's API settings) with the
right.
wall - Posting as the community requires both negative and
owner_id.from_group=1 - Rate/anti-spam: repeated identical posts or too-frequent posting can hit codes
like /
214— space posts out.219
- 参数是必填项——每次调用都必须包含,否则会返回错误。
v - 无法通过OAuth新生成用户令牌(用户令牌的隐式/授权码流程已于2024年6月禁用);请使用带有权限的社区访问密钥(无有效期限制,可在社区API设置中创建)。
wall - 以社区身份发帖时,必须同时设置为负数且传递
owner_id参数。from_group=1 - 频率/反垃圾机制:重复发布相同内容或发帖过于频繁可能会触发/
214等错误码——请间隔发帖。219