Skip to content

Commit

Permalink
2.0.23
Browse files Browse the repository at this point in the history
- Readme güncellemesi
  • Loading branch information
Hasokeyk committed Jul 21, 2022
1 parent 7223124 commit 5179847
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 2 deletions.
95 changes: 94 additions & 1 deletion README-TR.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Array

</details>

## iki Adımlı Giriş
## iki Adımlı Doğrulama Girişi

<details>
<summary>Örnek Kod</summary>
Expand Down Expand Up @@ -340,6 +340,99 @@ Array

</details>

## İki Adımlı Doğrulama & Şüpheli Girişi

<details>
<summary>Code</summary>

```php
<?php

use Hasokeyk\Interfaces\Instagram;

set_time_limit(0);

require "vendor/autoload.php";

$username = 'USERNAME';
$password = 'PASSWORD';
$license = 'LICENSE';

$instagram = new Instagram($license, $username, $password);

if(isset($_REQUEST['type']) and $_REQUEST['type'] == 'two_factor'){

$code = trim($_REQUEST['two_factor_login_code']);
$token = trim($_REQUEST['two_factor_identifier']);
$method = trim($_REQUEST['verification_method']);
$two_factor_login = $instagram->login->two_factor_login($code, $token, $method);
if($two_factor_login === true){
header("Refresh: 1; url=/");
}
else{
print_r($two_factor_login);
}

}
else if(isset($_REQUEST['type']) and $_REQUEST['type'] == 'challenge_send_code'){

$code = trim($_REQUEST['challenge_code']);
$user_id = trim($_REQUEST['user_id']);
$nonce_code = trim($_REQUEST['nonce_code']);
$challenge_login = $instagram->login->challenge_verify_code($code, $user_id, $nonce_code);
if($challenge_login === true){
header("Refresh: 1; url=/");
}
else{
print_r($challenge_login);
}

}
else{

$login = $instagram->login->login();
if(isset($login->status) and $login->status == 'two_factor'){

echo '
<h5>Two Factor</h5>
<br>
<form action="" method="get">
<input type="hidden" name="type" value="'.$login->status.'">
<input type="hidden" name="two_factor_identifier" value="'.$login->two_factor_identifier.'">
<input type="hidden" name="verification_method" value="'.$login->verification_method.'">
<input type="text" name="two_factor_login_code">
<input type="submit" value="Login">
</form>
';

}
else if(isset($login->status) and $login->status == 'challenge_send_code'){

echo '
<h5>Challenge</h5>
<br>
<form action="" method="get">
<input type="hidden" name="type" value="'.$login->status.'">
<input type="hidden" name="user_id" value="'.$login->user_id.'">
<input type="hidden" name="nonce_code" value="'.$login->nonce_code.'">
<input type="text" name="challenge_code">
<input type="submit" value="Login">
</form>
';

}
else if($login === false){
echo 'Login Fail';
}
else{
print_r($login);
}

}
```

</details>

## İki adımlı doğrulama kapatma/açma

<details>
Expand Down
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,99 @@ Array

</details>

## Two Factor & Challenge Login

<details>
<summary>Code</summary>

```php
<?php

use Hasokeyk\Interfaces\Instagram;

set_time_limit(0);

require "vendor/autoload.php";

$username = 'USERNAME';
$password = 'PASSWORD';
$license = 'LICENSE';

$instagram = new Instagram($license, $username, $password);

if(isset($_REQUEST['type']) and $_REQUEST['type'] == 'two_factor'){

$code = trim($_REQUEST['two_factor_login_code']);
$token = trim($_REQUEST['two_factor_identifier']);
$method = trim($_REQUEST['verification_method']);
$two_factor_login = $instagram->login->two_factor_login($code, $token, $method);
if($two_factor_login === true){
header("Refresh: 1; url=/");
}
else{
print_r($two_factor_login);
}

}
else if(isset($_REQUEST['type']) and $_REQUEST['type'] == 'challenge_send_code'){

$code = trim($_REQUEST['challenge_code']);
$user_id = trim($_REQUEST['user_id']);
$nonce_code = trim($_REQUEST['nonce_code']);
$challenge_login = $instagram->login->challenge_verify_code($code, $user_id, $nonce_code);
if($challenge_login === true){
header("Refresh: 1; url=/");
}
else{
print_r($challenge_login);
}

}
else{

$login = $instagram->login->login();
if(isset($login->status) and $login->status == 'two_factor'){

echo '
<h5>Two Factor</h5>
<br>
<form action="" method="get">
<input type="hidden" name="type" value="'.$login->status.'">
<input type="hidden" name="two_factor_identifier" value="'.$login->two_factor_identifier.'">
<input type="hidden" name="verification_method" value="'.$login->verification_method.'">
<input type="text" name="two_factor_login_code">
<input type="submit" value="Login">
</form>
';

}
else if(isset($login->status) and $login->status == 'challenge_send_code'){

echo '
<h5>Challenge</h5>
<br>
<form action="" method="get">
<input type="hidden" name="type" value="'.$login->status.'">
<input type="hidden" name="user_id" value="'.$login->user_id.'">
<input type="hidden" name="nonce_code" value="'.$login->nonce_code.'">
<input type="text" name="challenge_code">
<input type="submit" value="Login">
</form>
';

}
else if($login === false){
echo 'Login Fail';
}
else{
print_r($login);
}

}
```

</details>

## Disabled/Enabled Two Factor Verification

<details>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"license":"MIT",
"minimum-stability":"stable",
"require":{
"php": ">=7.4.0",
"php": ">=7.2",
"duosecurity/duo_api_php":"^1.0.3",
"guzzlehttp/guzzle":"^7.4.2",
"ext-json":"*"
Expand Down
83 changes: 83 additions & 0 deletions examples/user/two-factor-and-challenge-login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

use Hasokeyk\Interfaces\Instagram;

set_time_limit(0);

require "vendor/autoload.php";

$username = 'USERNAME';
$password = 'PASSWORD';
$license = 'LICENSE';

$instagram = new Instagram($license, $username, $password);

if(isset($_REQUEST['type']) and $_REQUEST['type'] == 'two_factor'){

$code = trim($_REQUEST['two_factor_login_code']);
$token = trim($_REQUEST['two_factor_identifier']);
$method = trim($_REQUEST['verification_method']);
$two_factor_login = $instagram->login->two_factor_login($code, $token, $method);
if($two_factor_login === true){
header("Refresh: 1; url=/");
}
else{
print_r($two_factor_login);
}

}
else if(isset($_REQUEST['type']) and $_REQUEST['type'] == 'challenge_send_code'){

$code = trim($_REQUEST['challenge_code']);
$user_id = trim($_REQUEST['user_id']);
$nonce_code = trim($_REQUEST['nonce_code']);
$challenge_login = $instagram->login->challenge_verify_code($code, $user_id, $nonce_code);
if($challenge_login === true){
header("Refresh: 1; url=/");
}
else{
print_r($challenge_login);
}

}
else{

$login = $instagram->login->login();
if(isset($login->status) and $login->status == 'two_factor'){

echo '
<h5>Two Factor</h5>
<br>
<form action="" method="get">
<input type="hidden" name="type" value="'.$login->status.'">
<input type="hidden" name="two_factor_identifier" value="'.$login->two_factor_identifier.'">
<input type="hidden" name="verification_method" value="'.$login->verification_method.'">
<input type="text" name="two_factor_login_code">
<input type="submit" value="Login">
</form>
';

}
else if(isset($login->status) and $login->status == 'challenge_send_code'){

echo '
<h5>Challenge</h5>
<br>
<form action="" method="get">
<input type="hidden" name="type" value="'.$login->status.'">
<input type="hidden" name="user_id" value="'.$login->user_id.'">
<input type="hidden" name="nonce_code" value="'.$login->nonce_code.'">
<input type="text" name="challenge_code">
<input type="submit" value="Login">
</form>
';

}
else if($login === false){
echo 'Login Fail';
}
else{
print_r($login);
}

}

0 comments on commit 5179847

Please sign in to comment.