Instagram 私人 API - 超出最大好友数,将关注者添加到亲密好友列表时出错

问题描述 投票:0回答:1

我正在使用 instagram-private-api 使用

setBesties
方法将关注者添加到亲密朋友列表中。一切正常,直到我的关注者达到 9,999 名,但一旦我尝试添加超出此数字的关注者,我就会收到以下错误:

Retry failed: IgResponseError: POST /api/v1/friendships/set_besties/ - 400 Bad Request; max besties exceeded
    at Request.handleResponseError (C:\Users\hamza\Desktop\instagram-close-friends-automation-ts\node_modules\instagram-private-api\src\core\request.ts:172:12)
    at Request.send (C:\Users\hamza\Desktop\instagram-close-friends-automation-ts\node_modules\instagram-private-api\src\core\request.ts:83:24)
    at async FriendshipRepository.setBesties (C:\Users\hamza\Desktop\instagram-close-friends-automation-ts\node_modules\instagram-private-api\src\repositories\friendship.repository.ts:76:22)

这是发生错误的代码部分:

await ig.friendship.setBesties({ add: batch, remove: [] });

以下是我用来将用户添加到好友列表的功能。

// Function to add followers to the close friends list
async function addToCloseFriends(ig: IgApiClient, followerIds: string[], batchSize: number, requestDelay: number, batchDelay: number) {
    let totalAdded = 0;
    console.log(`Adding ${followerIds.length} followers to close friends list...`);
    for (let i = 0; i < followerIds.length; i += batchSize) {
        const batch = followerIds.slice(i, i + batchSize);
        try {
            await ig.friendship.setBesties({ add: batch, remove: [] });
            totalAdded += batch.length;
            console.log(`Added batch ${Math.floor(i / batchSize) + 1} to close friends. Total added: ${totalAdded}`);
            await new Promise(resolve => setTimeout(resolve, requestDelay))
        } catch (error) {
            if (error instanceof IgNotFoundError) {
                console.error('An API endpoint was not found:', error.message);
            } else {
                console.error('An error occurred while adding to close friends:', error);
            }
            break;
        }
    
        await new Promise(resolve => setTimeout(resolve, batchDelay));
    }
    console.log('All followers have been added to the close friends list.');

一切正常,直到添加了 9999 个关注者,但之后,我一直收到 400 Bad Request 错误。

您可以添加到列表中的亲密朋友数量没有任何限制。我看到人们添加了超过 5 万粉丝。

我测试了较小的批次和较大的批次,但一旦达到 9,999 个关注者限制,错误就会持续出现。我尝试检查 API 文档以查看是否提到了此限制,但找不到任何有关好友列表中用户数量上限的明确信息。

如果存在 9,999 的隐藏上限,我想知道是否可以延长或绕过此限制,或者是否有任何其他解决方案允许在 Instagram 上管理更多用户作为“好友”。

typescript automation instagram-api http-status-code-400 instagram-graph-api
1个回答
0
投票

这取决于您使用的库以及方法的特定端点。它们可能已经过时了。

我需要更多信息:

您使用哪个库来实现此目的? 请求延迟是多少?您每天发出多少个请求? 您使用代理吗?

© www.soinside.com 2019 - 2024. All rights reserved.