Answer the question
In order to leave comments, you need to log in
Instagram private api login?
trying to get user 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' => 'Нет аккаунта'
]);
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"
]);
}
Answer the question
In order to leave comments, you need to log in
Instagram private api login?
Challenge requiredasks to verify the account via sms or email
In Russia, you need to go through the challenge, in the second code with SMS, there are no errors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question