您需要使用库提供的两种因素身份验证方法。这是一个例子:
<?php
set_time_limit(0);
date_default_timezone_set('UTC');
require __DIR__.'/../vendor/autoload.php';
/////// CONFIG ///////
$username = '';
$password = '';
$debug = true;
$truncatedDebug = false;
//////////////////////
$ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);
try {
$loginResponse = $ig->login($username, $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($username, $password, $twoFactorIdentifier, $verificationCode);
}
} catch (\Exception $e) {
echo 'Something went wrong: '.$e->getMessage()."\n";
}
在相关说明中,我无法从 GitHub 下载该软件包,因为它最近被删除了。你认为你可以只上传mgp25/instagram-php
包以便我下载吗?我将不胜感激!!