This repository has been archived by the owner on May 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
run.php
130 lines (111 loc) · 4.07 KB
/
run.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
use InstagramAPI\Exception\ChallengeRequiredException;
use InstagramAPI\Instagram;
require("lib/config.php");
require("lib/functions.php");
require('lib/cli.php');
$verification_method = 1; //0 = SMS, 1 = Email
$connection = [
'storage' => 'mysql',
'dbhost' => $db['host'],
'dbname' => $db['dbname'],
'dbusername' => $db['user'],
'dbpassword' => $db['pass'],
];
if (!$saveToDB) {
$connection = [];
}
class ExtendedInstagram extends Instagram
{
public function changeUser($username, $password)
{
$this->_setUser($username, $password);
}
}
function readln($prompt)
{
if (PHP_OS === 'WINNT') {
echo "$prompt ";
return trim((string)stream_get_line(STDIN, 6, "\n"));
}
return trim((string)readline("$prompt "));
}
$ig = new ExtendedInstagram($debug, $truncatedDebug, $connection);
try {
$ig->login($username, $password);
foreach ($showStoryUsername as $story_username):
$userID = $ig->people->getUserIdForName($story_username);
$storyFeed = $ig->story->getUserStoryFeed($userID);
// $photoFeed = $ig->timeline->getUserFeed($userID);
if ($storyFeed->getReel() == null) {
continue;
}
$storyItems = $storyFeed->getReel()->getItems();
$storyCount = count($storyItems);
for ($i = 0; $i < $storyCount; $i++) {
if ($storyItems[$i]->getStoryCta() == null) {
echo " ";
} else {
}
if ($storyItems[$i]->getMediaType() == 1) {
download($storyItems[$i]->getImageVersions2()->getCandidates()[0]->getUrl(), $story_username);
} else {
if ($storyItems[$i]->getStoryCta() == null) {
echo " ";
} else {
echo " & <a href='" . $storyItems[$i]->getStoryCta()[0]->getLinks()[0]->getWebUri() . "'>webUri</a>";
}
download($storyItems[$i]->getVideoVersions()[0]->getUrl(), $story_username);
}
}
endforeach;
echo "Berhasil";
} catch (\Exception $e) {
echo 'Something went wrong: ' . $e->getMessage() . "\n";
$response = $e->getResponse();
if ($e instanceof ChallengeRequiredException
&& $response->getErrorType() === 'checkpoint_challenge_required') {
sleep(3);
$checkApiPath = substr($response->getChallenge()->getApiPath(), 1);
$customResponse = $ig->request($checkApiPath)
->setNeedsAuth(false)
->addPost('choice', $verification_method)
->addPost('_uuid', $ig->uuid)
->addPost('guid', $ig->uuid)
->addPost('device_id', $ig->device_id)
->addPost('_uid', $ig->account_id)
->addPost('_csrftoken', $ig->client->getToken())
->getDecodedResponse();
} else {
echo "Not a challenge required exception...\n";
exit;
}
try {
if ($customResponse['status'] === 'ok' && $customResponse['action'] === 'close') {
echo 'Checkpoint bypassed';
exit();
}
$code = readln('Code that you received via ' . ($verification_method ? 'email' : 'sms') . ':');
$ig->changeUser($username, $password);
$customResponse = $ig->request($checkApiPath)
->setNeedsAuth(false)
->addPost('security_code', $code)
->addPost('_uuid', $ig->uuid)
->addPost('guid', $ig->uuid)
->addPost('device_id', $ig->device_id)
->addPost('_uid', $ig->account_id)
->addPost('_csrftoken', $ig->client->getToken())
->getDecodedResponse();
var_dump($customResponse);
if ($customResponse['status'] === 'ok') {
echo "Finished, logged in successfully! Run this file again to validate that it works.\n";
echo 'Harap mengaktifkan koneksi ke database agar tidak terkena checkpoint. Coba lagi';
} else {
echo "Probably finished...\n";
var_dump($customResponse);
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
// exit(0);
}