私人Instagram API |挑战必需的问题

时间:2018-12-05 07:18:19

标签: php instagram-api instagramapi-mgp25

我使用mgp25私人instagram api来满足我的需求。

我有时会遇到ChallengeRequired错误,我会通过以下方式解决该问题:

/**
 * Резолвим челлендж
 *
 * @param array $data
 * @return bool
 * @throws UserRegistrationException
 */
public function resolveChallenge(array $data): bool
{
    $this->client = $this->getInstagramClient();
    $this->client->changeUser($data['login'], $data['password']);

    $customResponse = $this->client->request($data['url'])->setNeedsAuth(false)->addPost("security_code", $data['code'])->getDecodedResponse();

    if (!is_array($customResponse)) {
        throw new Exception('Не удалось подтвердить вход');
    }

    $this->isMakeLogin = true;

    // Зашли
    if ($customResponse['status'] == "ok" && isset($customResponse['logged_in_user']) && (int)$customResponse['logged_in_user']['pk'] === (int)explode('/', $data['url'])[1]) {
        return $this->registerUserIfNotExists($data['login'], $data['password']);
    }

    // mgp25
    if ($customResponse['status'] === 'ok' && $customResponse['action'] === 'close') {
        return $this->registerUserIfNotExists($data['login'], $data['password']);
    }

    throw new Exception(isset($customResponse['message']) ? $customResponse['message'] : json_encode($customResponse));
}

解决挑战后,我将调用函数:

return $this->registerUserIfNotExists($data['login'], $data['password']);

哪个调用登录API方法并请求一些帐户数据,有时,我又一次遇到ChallengeRequired错误(循环)。

原因是什么?

0 个答案:

没有答案