跳到导航

只有视频号分享链接、sph短号或export编号,怎样接着查作品和评论?

查账号作品列表用 v2_…@finder,查某条作品的评论用数字作品 ID。 只有分享链接或搜一搜的 export/… 时,先用 data:wechat_channels.v2.fetch_video_detail 取作品详情,核对返回的标题和账号确实是目标视频,再用返回的数字作品 ID 查评论。sph… 账号短号要先用 data:wechat_channels.v2.fetch_channel_id_to_username 转换,才能查账号作品列表。

按手头的标识选择下一步

你已经拿到什么先做什么之后能继续做什么
v2_…@finder 账号编号直接用于账号作品列表整理作品目录或做号内主题搜索
App里的 sph… 账号短号用 data:wechat_channels.v2.fetch_channel_id_to_username 取 finder username再查转换出的账号的作品
某条视频的数字作品ID用 data:wechat_channels.v2.fetch_video_detail 查作品核对内容后看评论,或从返回账号继续取作品
搜一搜给出的 export/…作为详情的 export_id 输入从详情取得数字作品ID,再看评论
https://weixin.qq.com/sph/… 分享链接作为详情的 share_url 输入核对作品与账号后,进入评论或账号目录

export/… 用来在详情请求里定位作品;export/… 不是评论参数要求的数字作品 ID,不要直接传给评论请求。export/… 按复制到的原字符串保存,不要自己解码,也不要假定固定有效期。

搜一搜只留下一个 export/… 时,用 export/… 请求作品详情。拿到详情后,在表里同时填「搜索出口编号」和「已核对的数字作品 ID」。读评论用数字作品 ID;需要回看当时怎么找到作品时,从「搜索出口编号」一列查原搜索。

同事发来一条视频,怎样接着查评论?

把下面的请求体 POST 到 https://api.beatapi.io/v1/social-data/call,使用 BeatAPI Bearer 鉴权。把示例链接换成收到的完整视频号分享链接。

{"action":"wechat_channels.v2.fetch_video_detail","params":{"share_url":"https://weixin.qq.com/sph/example","raw":false}}

例如你收到一个新品介绍视频的分享链接,想知道视频发布在哪个账号、评论里还在问什么:

  1. 用分享链接取作品详情,确认返回的标题和账号确实是目标视频。
  2. 保存 data.id 作为作品 ID、data.username 作为账号标识,同时保存查询时间和原响应。
  3. 需要读反馈时,把作品 ID 交给评论流程;需要研究账号的更多作品时,把账号标识交给作品目录。

后续步骤直接复用已核对的作品 ID 和账号标识,不为整理一份表重复解析同一条链接。

可以这样告诉已接入 BeatAPI 的助手:

先确认这条视频的标题和发布账号,再整理这条作品的可见评论,找出与产品适用条件有关的疑问。保留原句与讨论上下文;如果需要看账号其他作品,先给我相关候选。

为什么传了链接,详情请求却查到另一条作品?

data:wechat_channels.v2.fetch_video_detail 按优先级使用输入:object_id、export_id、share_url。一次只填要查看的那一个目标;不要把旧作品 ID 和新分享链接放在同一请求里。

账号编号、作品 ID、父评论 ID 分别保存。object_nonce_id 是作品详情定位的辅助值,不是父评论的 comment_id。要展开回复时,使用评论响应里实际返回的父评论编号。

在本地准备一个明确目标

下文的 channels_identity.py 按一种输入类型生成请求文件;保存真实响应后,channels_identity.py 再生成账号作品列表或评论的后续请求,同时保留原件并核对返回标识。生成请求文件不会执行任何取数。

同一个可见字符串不是通用微信编号,所以先明确输入类型:

  • v2_…@finder 账号直接准备账号作品列表。
  • sph… 账号短号先转换。
  • 数字作品 ID、export/… 搜索标识和 HTTPS 视频号分享链接走作品详情。

channels_identity.py 不把账号名称或账号 ID 当作品 ID,也不会同时填写三个有优先级的详情目标字段。

  1. 把本页末尾的 Python 脚本保存为 channels_identity.py。
  2. 只运行与输入相符的那一条 prepare 命令。命令只生成 JSON,示例值是占位符:
python3 channels_identity.py prepare account 'COPIED_V2_USERNAME@finder' account-request
python3 channels_identity.py prepare channel 'COPIED_SPH_SHORT_ID' conversion-request
python3 channels_identity.py prepare export 'export/COPIED_EXACT_VALUE' detail-request
python3 channels_identity.py prepare video 'COPIED_NUMERIC_VIDEO_ID' detail-request
python3 channels_identity.py prepare link 'https://weixin.qq.com/sph/COPIED_SHARE_TOKEN' detail-request
  1. 把占位符换成复制来的完整原值;channels_identity.py 会拒绝占位符。真实分享链接必须使用 weixin.qq.com/sph/ 主机和路径,不能带查询串或片段。不要悄悄删掉多余的 URL 数据,也不要从任意分享文案猜 token。export 标识按不透明字符串原样保存:不解码、不改大小写、不从 export 标识计算作品 ID;export 标识也没有承诺的有效期。
  2. 核对 request.json 里选中的动作,再按价格页的当前单价估算解析请求和后续列表或评论请求的费用。已有可用标识时跳过解析;保存响应后在本地继续整理。
  3. 对已批准的转换或详情请求,在新目录里保存一次完整直接响应:
mkdir captured-call &&
curl --fail-with-body -sS https://api.beatapi.io/v1/social-data/call -H "Authorization: Bearer $BEATAPI_API_KEY" -H 'Content-Type: application/json' --data-binary @detail-request/request.json -D captured-call/headers.txt -o captured-call/response.json

转换 sph 短号时,改为发送 conversion-request/request.json。验证前检查 HTTP 状态和已存响应,不要向同一组文件重跑覆盖。

把已存解析结果交给正确的下一步

  1. 运行 python3 channels_identity.py verify detail-request/request.json captured-call/response.json identity-review。账号短号转换时,把请求文件换成 conversion-request/request.json。
  2. 了解 channels_identity.py verify 接受什么:
    • raw:false 的转换响应返回 data.channel_id 和 data.username。channels_identity.py 要求 channel_id 回显与输入一致,且 data.username 符合公开的 finder 格式。
    • 详情响应返回 data.id 和 data.username。channels_identity.py 只接受原始非零数字字符串或安全正整数;已被舍入的不安全数字 ID 无法补救。数字作品输入时,返回 ID 必须与请求 ID 完全一致。
    • export 或分享链接输入时,自己对照返回的标题和账号确认目标视频。本地来源哈希不能证明解析返回的是哪条作品。
  3. 查看私有输出目录 identity-review。目录里保留原始字节和身份审核记录,并包含未执行的 account-videos-request.json。作品详情有效时,还会生成 comments-request.json,内含这条作品的 ID、空父评论和首屏游标。account-videos-request.json 和 comments-request.json 是二选一的后续方向,只执行研究需要的那一个。

转换未命中、回显不一致、失败信封、username 格式不合格或作品 ID 不安全时,channels_identity.py verify 会在输出前停止。转换解析选中的是匹配的账号项,不证明账号归属;显示名相似也不足以确定后续目标。

选定并单独采集账号作品列表或评论步骤后,再用账号作品导出器或评论导出器导出。原始详情响应要留私有:原始详情响应可能含媒体 URL token 和解码密钥,账号与评论编号交接不需要媒体下载凭证。channels_identity.py 不下载、不解密媒体。来源哈希只检查本地字节一致性,不是服务器真实性签名。依据:已公开的微信视频号 v2 动作输入合同与响应结构。

import hashlib
import json
import os
import re
import sys
from pathlib import Path
os.umask(0o077)
DETAIL = 'wechat_channels.v2.fetch_video_detail'
CONVERT = 'wechat_channels.v2.fetch_channel_id_to_username'
LIST = 'wechat_channels.v2.fetch_user_videos'
def finder(value):
return isinstance(value, str) and 10 <= len(value) <= 256 and re.fullmatch(r'v2_[0-9a-fA-F]+@finder', value)
def numeric(value):
if type(value) is int and 0 < value <= 9007199254740991:
return str(value)
if isinstance(value, str) and re.fullmatch(r'[0-9]{1,32}', value) and any(c != '0' for c in value):
return value
raise ValueError('Require an original nonzero digit string or safe positive integer ID')
def prepare(kind, value):
params = {'raw': False}
if kind == 'account' and finder(value):
return {'action': LIST, 'params': {'username': value, 'raw': False, 'last_buffer': ''}}
if kind == 'channel' and len(value) <= 64 and re.fullmatch(r'sph[A-Za-z0-9_-]+', value):
return {'action': CONVERT, 'params': {'channel_id': value, 'raw': False}}
if kind == 'video':
params['object_id'] = numeric(value)
elif kind == 'export' and isinstance(value, str) and len(value) <= 2048 and re.fullmatch(r'export/[^\s]+', value):
params['export_id'] = value
elif kind == 'link' and len(value) <= 256 and re.fullmatch(r'https://weixin\.qq\.com/sph/[A-Za-z0-9]+/?', value):
params['share_url'] = value
else:
raise ValueError('Type does not match copied identifier; do not convert or infer it')
return {'action': DETAIL, 'params': params}
mode = sys.argv[1]
if mode == 'prepare':
kind, value, destination = sys.argv[2:5]
request = prepare(kind, value)
out = Path(destination)
files = {'request.json': request, 'audit.json': {'input_kind': kind, 'executed_calls': 0, 'target_review_required': True}}
archives = {}
elif mode == 'verify':
request_file, response_file, destination = map(Path, sys.argv[2:5])
request_bytes, raw = request_file.read_bytes(), response_file.read_bytes()
request, response = json.loads(request_bytes), json.loads(raw)
if not isinstance(request, dict) or set(request) != {'action', 'params'}:
raise ValueError('Use the saved prepared request')
action, params = request['action'], request['params']
if not isinstance(params, dict) or params.get('raw') is not False:
raise ValueError('This verifier requires explicit raw:false')
if action == CONVERT and set(params) == {'channel_id', 'raw'}:
expected = prepare('channel', params['channel_id'])
elif action == DETAIL:
fields = [key for key in ['object_id', 'export_id', 'share_url'] if key in params]
if len(fields) != 1 or set(params) != {'raw', fields[0]}:
raise ValueError('Exactly one target identifier; no priority ambiguity')
field = fields[0]
expected = prepare({'object_id':'video', 'export_id':'export', 'share_url':'link'}[field], params[field])
else:
raise ValueError('Verify only channel conversion or video detail here')
if request != expected:
raise ValueError('Prepared request changed')
if not isinstance(response, dict) or response.get('status') != 'succeeded' or response.get('action') != action or response.get('error') is not None:
raise ValueError('Expected successful matching action response')
rid, data = response.get('request_id'), response.get('data')
if not isinstance(rid, str) or not rid.strip() or not isinstance(data, dict) or data.get('error') not in (None, ''):
raise ValueError('Missing provenance, no match or invalid data')
username = data.get('username')
if not finder(username):
raise ValueError('No valid finder username; do not use display name instead')
if any(data.get(key) is not None and not isinstance(data[key], str) for key in ['nickname', 'title']):
raise ValueError('Expected text title/nickname')
audit = {'action': action, 'request_id': rid, 'request_sha256': hashlib.sha256(request_bytes).hexdigest(), 'response_sha256': hashlib.sha256(raw).hexdigest(), 'username': username, 'nickname': data.get('nickname'), 'title': data.get('title'), 'executed_calls': 0, 'target_review_required': True}
files = {'account-videos-request.json': prepare('account', username)}
if action == CONVERT:
if data.get('channel_id') != params['channel_id']:
raise ValueError('Conversion input echo does not match')
audit['channel_id'] = params['channel_id']
else:
object_id = numeric(data.get('id'))
if 'object_id' in params and object_id != params['object_id']:
raise ValueError('Returned object ID does not match requested video')
audit['object_id'] = object_id
audit['target_check'] = 'For export/share input, review returned title/account against intended video; a local hash does not prove resolution identity'
files['comments-request.json'] = {'action':'wechat_channels.v2.fetch_video_comments', 'params':{'object_id':object_id, 'comment_id':'', 'last_buffer':'', 'raw':False}}
files['identity-audit.json'] = audit
archives = {'source-request.json': request_bytes, 'source-response.json': raw}
out = destination
else:
raise ValueError('Use prepare TYPE VALUE OUTPUT or verify REQUEST RESPONSE OUTPUT')
out.mkdir(mode=0o700, exist_ok=False)
for name, value in files.items():
(out/name).write_text(json.dumps(value, ensure_ascii=False, indent=2), encoding='utf-8')
for name, value in archives.items():
(out/name).write_bytes(value)
print(str(out))