пытаюсь получить id пользователя
Instagram::$allowDangerousWebUsageAtMyOwnRisk=true;
$ig = new Instagram(true,true);
$ig->login($request->login, $request->password);
$userId = $ig->people->getUserIdForName($request->login);
if ($userId) return response()->json([
'error' => 1,
'message' => $userId
]);else return response()->json([
'error' => 1,
'message' => 'Нет аккаунта'
]);
но выдает
I
nstagramAPI\Response\LoginResponse: Challenge required.
Пробую вот так, но тоже выдает ту ошибку
Instagram::$allowDangerousWebUsageAtMyOwnRisk=true;
$debug = true;
$truncatedDebug = false;
$ig = new Instagram($debug, $truncatedDebug);
try {
$loginResponse = $ig->login($request->login, $request->password);
if ($loginResponse !== null && $loginResponse->isTwoFactorRequired()) {
$twoFactorIdentifier = $loginResponse->getTwoFactorInfo()->getTwoFactorIdentifier();
// The "STDIN" lets you paste the code via terminal for testing.
// You should replace this line with the logic you want.
// The verification code will be sent by Instagram via SMS.
$verificationCode = trim(fgets(STDIN));
$ig->finishTwoFactorLogin($request->login, $request->password, $twoFactorIdentifier, $verificationCode);
}
} catch (\Exception $e) {
return response()->json([
'error' => 1,
'message' => 'Something went wrong: '.$e->getMessage()."\n"
]);
}