DIYgod/RSSHub · error · RejectError

无法获取用户信息

Error message

无法获取用户信息

What it means

A `RejectError` thrown at lib/routes/toutiao/user.tsx:61 when Toutiao's feed API (`/api/pc/list/feed`) returned no usable `data.data` array. Toutiao employs aggressive anti-crawler protection via the `a_bogus` signature parameter; if the signature is stale, the token is invalid, or the IP is flagged, the API returns an anti-bot response with no feed items. The route is marked `antiCrawler: true`.

Source

Thrown at lib/routes/toutiao/user.tsx:61

        `toutiao:user:${token}`,
        async () => {
            const query = `category=profile_all&token=${token}&max_behot_time=0&entrance_gid&aid=24&app_name=toutiao_web`;

            const headers = generateHeaders(PRESETS.MODERN_WINDOWS_CHROME);
            const userAgent = headers['user-agent'];

            const data = await ofetch(`https://www.toutiao.com/api/pc/list/feed?${query}&a_bogus=${generate_a_bogus(query, userAgent)}`, {
                headerGeneratorOptions: PRESETS.MODERN_WINDOWS_CHROME,
            });

            return data.data;
        },
        config.cache.routeExpire,
        false
    )) as Feed[];

    if (!feed) {
        throw new RejectError('无法获取用户信息');
    }

    const items = feed.map((item) => {
        switch (item.cell_type) {
            case 0:
            case 49: {
                const video = item.video.play_addr_list.toSorted((a, b) => b.bitrate - a.bitrate)[0];
                const user = item.user as UserInfoCell49 | undefined;
                return {
                    title: item.title,
                    description: renderVideo(item.video.play_addr_list.toSorted((a, b) => b.bitrate - a.bitrate)[0].play_url_list[0], item.video.origin_cover.url_list[0]),
                    link: `https://www.toutiao.com/video/${item.id}/`,
                    pubDate: parseDate(item.publish_time, 'X'),
                    author: user?.info.name ?? item.source,
                    enclosure_url: video?.play_url_list[0],
                    enclosure_type: video?.play_url_list[0] ? 'video/mp4' : undefined,
                    user: {
                        name: user?.info.name,

View on GitHub (pinned to bed535e087)

Solutions

  1. Update the `generate_a_bogus` implementation in lib/routes/toutiao/a-bogus to match Toutiao's current JS algorithm (capture a live request and diff).
  2. Verify the token by opening `https://www.toutiao.com/c/user/token/{token}/` in a browser.
  3. Run RSSHub from a residential IP or use a proxy to avoid bot-detection flagging.
  4. Clear cache key `toutiao:user:{token}` to force a fresh signed request.
Defensive patterns

Strategy: retry

Type guard

const isFeedArray = (d: unknown): d is Feed[] =>
    Array.isArray(d) && d.length > 0;

Try / catch

try {
    const feed = await getToutiaoFeed(token);
} catch (e) {
    if (e instanceof RejectError) {
        // a_bogus signature likely stale or IP flagged — retry after updating algorithm
        throw new Error('Toutiao anti-crawler blocked the request; update a_bogus or rotate IP');
    }
    throw e;
}

Prevention

When it happens

Trigger: The `generate_a_bogus` function in ./a-bogus is outdated and Toutiao's algorithm changed; the user token (`MS4wLjAB...`) is invalid or the account is banned; the requesting IP is rate-limited or geo-blocked; the ofetch call was intercepted by a Cloudflare/Toutiao challenge page that returns HTML instead of JSON.

Common situations: Toutiao rotates the a_bogus algorithm periodically, breaking the route; self-hosted RSSHub on a datacenter IP gets flagged; token copied from an expired session.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/4813239659ea4cd6. Report an issue: GitHub.