· 6 years ago · Nov 28, 2019, 01:06 PM
1<?php
2
3require __DIR__ . '/vendor/autoload.php';
4$ig = new \InstagramAPI\Instagram();
5$climate = new \League\CLImate\CLImate();
6$climate->green()->bold(
7 "
8 _ _
9| | | |
10| |__ _ _ _ __ ___ _ ____ _____ | |_ ___ _ __
11| '_ \| | | | '_ \ / _ \ '__\ \ / / _ \| __/ _ \ '__|
12| | | | |_| | |_) | __/ | \ V / (_) | || __/ |
13|_| |_|\__, | .__/ \___|_| \_/ \___/ \__\___|_|
14 __/ | |
15 |___/|_|"
16);
17output_clean( '' );
18$climate->green()->bold( 'Hypervoter Terminal' );
19$climate->green()->bold( 'v1.7.1' );
20output_clean( '' );
21$climate->green( '© Developed by HyperVoter (https://hypervoter.com)' );
22output_clean( '' );
23run( $ig, $climate );
24
25/**
26 * Let's start the show
27 */
28function run( $ig, $climate ) {
29
30 $poll_active = $slider_active = $question_active = $quiz_active = false;
31
32 try {
33 $climate->out( 'Please provide an username for config file...' );
34 $config_name = getVarFromUser( 'Username' );
35 if ( empty( $config_name ) ) {
36 do {
37 $config_name = getVarFromUser( 'Username' );
38 } while ( empty( $config_name ) );
39 }
40 $climate->infoBold( 'Checking for config...' );
41 sleep( 1 );
42 if ( file_exists( './config/config-' . $config_name . '.json' ) ) {
43 $climate->infoBold( 'Config file found. Processing...' );
44 sleep( 1 );
45 $mafile = fopen( './config/config-' . $config_name . '.json', 'r' );
46 $file = fread( $mafile, filesize( './config/config-' . $config_name . '.json' ) );
47 $data = json_decode( $file );
48 fclose( $mafile );
49 $climate->infoBold( 'Checking & Validating License key...' );
50 sleep( 1 );
51 if ( $data->license_key !== '' ) {
52 $license_status = activate_license( $data->license_key, $ig );
53 } else {
54 $climate->backgroundRedWhiteBold( 'null' );
55 sleep( 1 );
56 exit();
57 }
58
59 if ( 'valid' === $license_status ) {
60 $climate->backgroundBlueWhiteBold( ' You license key is active and valid. Processing... ' );
61 sleep( 1 );
62
63 if ( '' !== $data->username ) {
64 $climate->infoBold( 'Username Found' );
65 $login = $data->username;
66 } else {
67 $climate->backgroundRedWhiteBold( 'Username can not empty' );
68 sleep( 1 );
69 exit();
70 }
71 if ( '' !== $data->password ) {
72 $climate->infoBold( 'Password Found' );
73 $password = $data->password;
74 } else {
75 $climate->backgroundRedWhiteBold( 'Password can not empty' );
76 sleep( 1 );
77 exit();
78 }
79 if ( '3' === $data->proxy ) {
80 $climate->infoBold( 'Proxy Skipping Enabled. Processing ...' );
81 sleep( 1 );
82 } else {
83 $climate->infoBold( 'Proxy Option found. Validating...' );
84 sleep( 1 );
85 $validate_proxy = isValidProxy( $data->proxy, $climate );
86 $climate->infoBold( 'Proxy Status : ' . $validate_proxy );
87
88 if ( $validate_proxy == 200 ) {
89 $climate->info( 'Proxy Connected. Processing ...' );
90 $ig->setProxy( $data->proxy );
91 } else {
92 $climate->info( 'Proxy can not conntected. Skipping...' );
93 }
94 }
95
96 if ( $data->speed_value ) {
97 $climate->infoBold( 'Speed Value Found. Processing ... ' );
98 $speed = (int) $data->speed_value;
99
100 if ( $speed > 1500000 ) {
101 do {
102 $climate->errorBold( 'Speed value is incorrect. Type integer value from 1 to 1 500 000 stories/day.' );
103 usleep( 500000 );
104 $climate->errorBold( 'For Maxiumum speed please use "0"... Please set speed now (that will not change your config file)' );
105 $speed = (int) getVarFromUser( 'Speed' );
106 } while ( $speed > 1500000 );
107 }
108
109 if ( $speed === 0 ) {
110 $climate->infoBold( ' Maximum speed enabled. ' );
111 $delay = 46;
112 } else {
113 $climate->infoBold( 'Speed set to ' . $speed . ' stories/day.' );
114 $delay = round( 60 * 60 * 24 * 10 / $speed );
115 }
116 }
117
118 if ( $data->fresh_stories_range > 0 ) {
119 $fresh_stories_range = $data->fresh_stories_range;
120 $climate->infoBold( 'Experimental Feature (Fresh Stories Range) value found. Validating ...' );
121 sleep( 1 );
122 if ( $fresh_stories_range > 23 ) {
123 do {
124 $climage->errorBold( 'Fresh stories range value is incorrect. Type integer value from 1 to 23.' );
125 $climage->errorBold( 'Type 0 for skip this option.' );
126 $fresh_stories_range = (int) getVarFromUser( 'Fresh Stories Range' );
127 } while ( $fresh_stories_range > 23 );
128 }
129 $climate->infoBold( 'Fresh Stories Range set to ' . $fresh_stories_range );
130 sleep( 1 );
131 } else {
132 $fresh_stories_range = 0;
133 $climate->infoBold( 'Experimental Feature (Fresh Stories Range) Skipping.' );
134 usleep( 500000 );
135 }
136
137 $defined_targets = $data->targets;
138 $poll_active = $data->is_poll_vote_active;
139 $slider_active = $data->is_slider_points_active;
140 $question_active = $data->is_questions_answers_active;
141 $quiz_active = $data->is_quiz_answers_active;
142
143 } else {
144 $climate->backgroundRedWhiteBold( ' You license key is not valid. Please obtain valid licence key from your Dashboard on Hypervoter.com (https://hypervoter.com) ' );
145 sleep( 1 );
146 exit();
147 }
148 } else {
149 sleep( 5 );
150 $defined_targets = null;
151
152
153
154
155 $climate->out( 'Please provide login data of your Instagram Account.' );
156
157 $login = getVarFromUser( 'Login' );
158 if ( empty( $login ) ) {
159 do {
160 $login = getVarFromUser( 'Login' );
161 } while ( empty( $login ) );
162 }
163
164 $password = getVarFromUser( 'Password' );
165 if ( empty( $password ) ) {
166 do {
167 $password = getVarFromUser( 'Password' );
168 } while ( empty( $password ) );
169 }
170
171 $first_loop = true;
172 do {
173 if ( $first_loop ) {
174 $climate->out( "(Optional) Set proxy, if needed. It's better to use a proxy from the same country where you running this script." );
175 $climate->out( 'Proxy should match following pattern:' );
176 $climate->out( 'http://ip:port or http://username:password@ip:port' );
177 $climate->out( "Don't use in pattern https://." );
178 $climate->out( "Type 3 to skip and don't use proxy." );
179 $first_loop = false;
180 } else {
181 $climate->out( 'Proxy - [NOT VALID]' );
182 $climate->out( 'Please check the proxy syntax and try again.' );
183 }
184
185 $proxy = getVarFromUser( 'Proxy' );
186
187 if ( empty( $proxy ) ) {
188 do {
189 $proxy = getVarFromUser( 'Proxy' );
190 } while ( empty( $proxy ) );
191 }
192
193 if ( $proxy == '3' ) {
194 // Skip proxy setup
195 break;
196 }
197 } while ( ! isValidProxy( $proxy, $climate ) );
198
199 $proxy_check = isValidProxy( $proxy, $climate );
200 if ( $proxy == '3' ) {
201 $climate->info( 'Proxy Setup Skipped' );
202 } elseif ( $proxy_check == 500 ) {
203 $climate->info( 'Proxy is not valid. Skipping' );
204 } else {
205 $climate->info( 'Proxy - [OK]' );
206 $ig->setProxy( $proxy );
207 }
208
209 $climate->out( 'Please choose the Hypervote estimated speed.' );
210 $climate->out( 'Type integer value without spaces from 1 to 1 500 000 stories/day or 0 for maximum possible speed.' );
211 $climate->out( 'We recommend you set 400000 stories/day. This speed works well for a long time without exceeding the limits.' );
212 $climate->out( 'When you are using the maximum speed you may exceed the Hypervote limits per day if this account actively used by a user in the Instagram app at the same time.' );
213 $climate->out( 'If you are using another type of automation, we recommend to you reducing Hypervote speed and find your own golden ratio.' );
214 $speed = (int) getVarFromUser( 'Speed' );
215
216 if ( $speed > 1500000 ) {
217 do {
218 $climate->out( 'Speed value is incorrect. Type integer value from 1 to 1 500 000 stories/day.' );
219 $climate->out( 'Type 0 for maximum speed.' );
220 $speed = (int) getVarFromUser( 'Delay' );
221 } while ( $speed > 1500000 );
222 }
223
224 if ( $speed == 0 ) {
225 $climate->out( 'Maximum speed enabled.' );
226 $delay = 46;
227 } else {
228 $climate->out( 'Speed set to ' . $speed . ' stories/day.' );
229 $delay = round( 60 * 60 * 24 * 10 / $speed );
230 }
231
232 $climate->out( 'Experimental features:' );
233 $climate->out( 'Voting only fresh stories, which posted no more than X hours ago.' );
234 $climate->out( 'X - is integer value from 1 to 23.' );
235 $climate->out( 'Type 0 to skip this option.' );
236 $climate->out( 'This option will reduce speed, but can increase results of Hypervote.' );
237 $fresh_stories_range = (int) getVarFromUser( 'X' );
238
239 if ( $fresh_stories_range > 23 ) {
240 do {
241 $climate->out( 'Fresh stories range value is incorrect. Type integer value from 1 to 23.' );
242 $climate->out( 'Type 0 for skip this option.' );
243 $fresh_stories_range = (int) getVarFromUser( 'X' );
244 } while ( $fresh_stories_range > 23 );
245 }
246
247 $q_answers = (int) getVarFromUser( 'Is Question Answers active? (0/1)' );
248 $q_vote = (int) getVarFromUser( 'Is Poll Vote active? (0/1)' );
249 $q_slide = (int) getVarFromUser( 'Is Slide Points active? (0/1)' );
250 $q_quiz = (int) getVarFromUser( 'Is Quiz Answers active? (0/1)' );
251 $q_quiz = (int) getVarFromUser( 'Is Story Masslooking active? (0/1)' );
252
253 if ( $q_answers !== 0 ) {
254 $q_answers_a = getVarFromUser( 'Please provide your answers (in comma seperated)' );
255 }
256 if ( $q_slide !== 0 ) {
257 $q_slide_pointsMin = (int) getVarFromUser( 'Please Provide Min. Slide Points (0/100)' );
258 $q_slide_pointsMax = (int) getVarFromUser( 'Please Provide Max. Slide Points (0/100)' );
259 }
260
261 if ( ! empty( $q_answers_a ) ) {
262 $qs = explode( ',', $q_answers_a );
263 } else {
264 $qs = array();
265 }
266
267 $datas = json_encode(
268 array(
269 'is_poll_vote_active' => ( $q_vote === 0 ) ? false : true,
270 'is_slider_points_active' => ( $q_slide === 0 ) ? false : true,
271 'is_questions_answers_active' => ( $q_answers === 0 ) ? false : true,
272 'is_quiz_answers_active' => ( $q_quiz === 0 ) ? false : true,
273 'questions_answers' => $qs,
274 'slider_points_range' => array(
275 ( $q_slide_pointsMin ) ? $q_slide_pointsMin : 0,
276 ( $q_slide_pointsMax ) ? $q_slide_pointsMax : 100,
277
278 ),
279
280 )
281 );
282
283 $data = json_decode( $datas );
284
285 }
286
287 $is_connected = false;
288 $is_connected_count = 0;
289 $fail_message = "There is a problem with your Ethernet connection or Instagram is down at the moment. We couldn't establish connection with Instagram 10 times. Please try again later.";
290
291 do {
292 if ( $is_connected_count == 10 ) {
293 if ( $e->getResponse() ) {
294 $climate->errorBold( $e->getMessage() );
295 }
296 throw new Exception( $fail_message );
297 }
298
299 try {
300 if ( $is_connected_count == 0 ) {
301 $climate->infoBold( 'Emulation of an Instagram app initiated...' );
302 }
303 $login_resp = $ig->login( $login, $password );
304
305 if ( $login_resp !== null && $login_resp->isTwoFactorRequired() ) {
306 // Default verification method is phone
307 $twofa_method = '1';
308
309 // Detect is Authentification app verification is available
310 $is_totp = json_decode( json_encode( $login_resp ), true );
311 if ( $is_totp['two_factor_info']['totp_two_factor_on'] == '1' ) {
312 $climate->infoBold( 'Two-factor authentication required, please enter the code from you Authentication app' );
313 $twofa_id = $login_resp->getTwoFactorInfo()->getTwoFactorIdentifier();
314 $twofa_method = '3';
315 } else {
316 $climate->bold(
317 'Two-factor authentication required, please enter the code sent to your number ending in %s',
318 $login_resp->getTwoFactorInfo()->getObfuscatedPhoneNumber()
319 );
320 $twofa_id = $login_resp->getTwoFactorInfo()->getTwoFactorIdentifier();
321 }
322
323 $twofa_code = getVarFromUser( 'Two-factor code' );
324
325 if ( empty( $twofa_code ) ) {
326 do {
327 $twofa_code = getVarFromUser( 'Two-factor code' );
328 } while ( empty( $twofa_code ) );
329 }
330
331 $is_connected = false;
332 $is_connected_count = 0;
333 do {
334 if ( $is_connected_count == 10 ) {
335 if ( $e->getResponse() ) {
336 $climate->errorBold( $e->getMessage() );
337 }
338 throw new Exception( $fail_message );
339 }
340
341 if ( $is_connected_count == 0 ) {
342 $climate->infoBold( 'Two-factor authentication in progress...' );
343 }
344
345 try {
346 $twofa_resp = $ig->finishTwoFactorLogin( $login, $password, $twofa_id, $twofa_code, $twofa_method );
347 $is_connected = true;
348 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
349 sleep( 7 );
350 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
351 sleep( 7 );
352 } catch ( \InstagramAPI\Exception\InvalidSmsCodeException $e ) {
353 $is_code_correct = false;
354 $is_connected = true;
355 do {
356 $climate->errorBold( 'Code is incorrect. Please check the syntax and try again.' );
357 $twofa_code = getVarFromUser( 'Two-factor code' );
358
359 if ( empty( $twofa_code ) ) {
360 do {
361 $twofa_code = getVarFromUser( 'Security code' );
362 } while ( empty( $twofa_code ) );
363 }
364
365 $is_connected = false;
366 $is_connected_count = 0;
367 do {
368 try {
369 if ( $is_connected_count == 10 ) {
370 if ( $e->getResponse() ) {
371 output( $e->getMessage() );
372 }
373 throw new Exception( $fail_message );
374 }
375
376 if ( $is_connected_count == 0 ) {
377 $climate->infoBold( 'Verification in progress...' );
378 }
379 $twofa_resp = $ig->finishTwoFactorLogin( $login, $password, $twofa_id, $twofa_code, $twofa_method );
380 $is_code_correct = true;
381 $is_connected = true;
382 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
383 sleep( 7 );
384 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
385 sleep( 7 );
386 } catch ( \InstagramAPI\Exception\InvalidSmsCodeException $e ) {
387 $is_code_correct = false;
388 $is_connected = true;
389 } catch ( \Exception $e ) {
390 throw $e;
391 }
392 $is_connected_count += 1;
393 } while ( ! $is_connected );
394 } while ( ! $is_code_correct );
395 } catch ( \Exception $e ) {
396 throw $e;
397 }
398
399 $is_connected_count += 1;
400 } while ( ! $is_connected );
401 }
402
403 $is_connected = true;
404 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
405 sleep( 7 );
406 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
407 sleep( 7 );
408 } catch ( \InstagramAPI\Exception\CheckpointRequiredException $e ) {
409 throw new Exception( 'Please go to Instagram website or mobile app and pass checkpoint!' );
410 } catch ( \InstagramAPI\Exception\ChallengeRequiredException $e ) {
411
412 if ( ! ( $ig instanceof InstagramAPI\Instagram ) ) {
413 throw new Exception( 'Oops! Something went wrong. Please try again later! (invalid_instagram_client)' );
414 }
415
416 if ( ! ( $e instanceof InstagramAPI\Exception\ChallengeRequiredException ) ) {
417 throw new Exception( 'Oops! Something went wrong. Please try again later! (unexpected_exception)' );
418 }
419
420 if ( ! $e->hasResponse() || ! $e->getResponse()->isChallenge() ) {
421 throw new Exception( 'Oops! Something went wrong. Please try again later! (unexpected_exception_response)' );
422 }
423
424 $challenge = $e->getResponse()->getChallenge();
425
426 if ( is_array( $challenge ) ) {
427 $api_path = $challenge['api_path'];
428 } else {
429 $api_path = $challenge->getApiPath();
430 }
431
432 $climate->info( 'Instagram want to send you a security code to verify your identity.' );
433 $climate->info( 'How do you want receive this code?' );
434 $climate->infoBold( '1 - [Email]' );
435 $climate->infoBold( '2 - [SMS]' );
436 $climate->infoBold( '3 - [Exit]' );
437
438 $choice = getVarFromUser( 'Choice' );
439
440 if ( empty( $choice ) ) {
441 do {
442 $choice = getVarFromUser( 'Choice' );
443 } while ( empty( $choice ) );
444 }
445
446 if ( $choice == '1' || $choice == '2' || $choice == '3' ) {
447 // All fine
448 } else {
449 $is_choice_ok = false;
450 do {
451 $climate->errorBold( 'Choice is incorrect. Type 1, 2 or 3.' );
452 $choice = getVarFromUser( 'Choice' );
453
454 if ( empty( $choice ) ) {
455 do {
456 $choice = getVarFromUser( 'Choice' );
457 } while ( empty( $choice ) );
458 }
459
460 if ( $confirm == '1' || $confirm == '2' || $confirm == '3' ) {
461 $is_choice_ok = true;
462 }
463 } while ( ! $is_choice_ok );
464 }
465
466 $challange_choice = 0;
467 if ( $choice == '3' ) {
468 run( $ig, $climate );
469 } elseif ( $choice == '1' ) {
470 // Email
471 $challange_choice = 1;
472 } else {
473 // SMS
474 $challange_choice = 0;
475 }
476
477 $is_connected = false;
478 $is_connected_count = 0;
479 do {
480 if ( $is_connected_count == 10 ) {
481 if ( $e->getResponse() ) {
482 $climate->errorBold( $e->getMessage() );
483 }
484 throw new Exception( $fail_message );
485 }
486
487 try {
488 $challenge_resp = $ig->sendChallangeCode( $api_path, $challange_choice );
489
490 // Failed to send challenge code via email. Try with SMS.
491 if ( $challenge_resp->status != 'ok' ) {
492 $challange_choice = 0;
493 sleep( 7 );
494 $challenge_resp = $ig->sendChallangeCode( $api_path, $challange_choice );
495 }
496
497 $is_connected = true;
498 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
499 sleep( 7 );
500 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
501 sleep( 7 );
502 } catch ( \Exception $e ) {
503 throw $e;
504 }
505
506 $is_connected_count += 1;
507 } while ( ! $is_connected );
508
509 if ( $challenge_resp->status != 'ok' ) {
510 if ( isset( $challenge_resp->message ) ) {
511 if ( $challenge_resp->message == 'This field is required.' ) {
512 $climate->info( "We received the response 'This field is required.'. This can happen in 2 reasons:" );
513 $climate->info( '1. Instagram already sent to you verification code to your email or mobile phone number. Please enter this code.' );
514 $climate->info( '2. Instagram forced you to phone verification challenge. Try login to Instagram app or website and take a look at what happened.' );
515 }
516 } else {
517 $climate->info( 'Instagram Response: ' . json_encode( $challenge_resp ) );
518 $climate->info( "Couldn't send a verification code for the login challenge. Please try again later." );
519 $climate->info( '- Is this account has attached mobile phone number in settings?' );
520 $climate->info( '- If no, this can be a reason of this problem. You should add mobile phone number in account settings.' );
521 throw new Exception( '- Sometimes Instagram can force you to phone verification challenge process.' );
522 }
523 }
524
525 if ( isset( $challenge_resp->step_data->contact_point ) ) {
526 $contact_point = $challenge_resp->step_data->contact_point;
527 if ( $choice == 2 ) {
528 $climate->info( 'Enter the code sent to your number ending in ' . $contact_point . '.' );
529 } else {
530 $climate->info( 'Enter the 6-digit code sent to the email address ' . $contact_point . '.' );
531 }
532 }
533
534 $security_code = getVarFromUser( 'Security code' );
535
536 if ( empty( $security_code ) ) {
537 do {
538 $security_code = getVarFromUser( 'Security code' );
539 } while ( empty( $security_code ) );
540 }
541
542 if ( $security_code == '3' ) {
543 throw new Exception( 'Reset in progress...' );
544 }
545
546 // Verification challenge
547 $ig = challange( $ig, $login, $password, $api_path, $security_code, $proxy, $climate );
548
549 } catch ( \InstagramAPI\Exception\AccountDisabledException $e ) {
550 throw new Exception( 'Your account has been disabled for violating Instagram terms. Go Instagram website or mobile app to learn how you may be able to restore your account.' );
551 } catch ( \InstagramAPI\Exception\ConsentRequiredException $e ) {
552 throw new Exception( 'Instagram updated Terms and Data Policy. Please go to Instagram website or mobile app to review these changes and accept them.' );
553 } catch ( \InstagramAPI\Exception\SentryBlockException $e ) {
554 throw new Exception( 'Access to Instagram API restricted for spam behavior or otherwise abusing. You can try to use Session Catcher script (available by https://nextpost.tech/session-catcher) to get valid Instagram session from location, where your account created from.' );
555 } catch ( \InstagramAPI\Exception\IncorrectPasswordException $e ) {
556 throw new Exception( 'The password you entered is incorrect. Please try again.' );
557 } catch ( \InstagramAPI\Exception\InvalidUserException $e ) {
558 throw new Exception( "The username you entered doesn't appear to belong to an account. Please check your username in config file and try again." );
559 } catch ( \Exception $e ) {
560 throw $e;
561 }
562
563 $is_connected_count += 1;
564 } while ( ! $is_connected );
565
566 $climate->infoBold( 'Logged as @' . $login . ' successfully.' );
567
568 $data_targ = define_targets( $ig, $defined_targets, $climate );
569
570 hypervote_v1( $data, $data_targ, $ig, $delay, $fresh_stories_range, $climate );
571
572 } catch ( \Exception $e ) {
573 $climate->errorBold( $e->getMessage() );
574 sleep( 1 );
575 $climate->errorBold( 'Please run script command again.' );
576 exit;
577 }
578}
579
580/**
581 * Define targets for Hypervote
582 */
583function define_targets( $ig, $defined_targets = null, $climate ) {
584
585 do {
586 if ( null === $defined_targets ) {
587 $climate->out( 'Please define the targets.' );
588 $climate->out( "Write all Instagram profile usernames via comma without '@' symbol." );
589 $climate->out( 'Example: apple, instagram, hostazor' );
590 $targets_input = getVarFromUser( 'Usernames' );
591
592 if ( empty( $targets_input ) ) {
593 do {
594 $targets_input = getVarFromUser( 'Usernames' );
595 } while ( empty( $targets_input ) );
596 }
597 } else {
598 $climate->infoBold( 'Targets already defined config file. Applying...' );
599 sleep( 1 );
600 $targets_input = $defined_targets;
601 }
602
603 $targets_input = str_replace( ' ', '', $targets_input );
604 $targets = [];
605 $targets = explode( ',', trim( $targets_input ) );
606 $targets = array_unique( $targets );
607
608 $pks = [];
609 $filtered_targets = [];
610 foreach ( $targets as $target ) {
611
612 $is_connected = false;
613 $is_connected_count = 0;
614 do {
615 if ( $is_connected_count == 10 ) {
616 if ( $e->getResponse() ) {
617 $climate->errorBold( $e->getMessage() );
618 }
619 $fail_message = "There is a problem with your Ethernet connection or Instagram is down at the moment. We couldn't establish connection with Instagram 10 times. Please try again later.";
620 $climate->errorBold( $fail_message );
621 run( $ig, $climate );
622 }
623
624 try {
625 $user_resp = $ig->people->getUserIdForName( $target );
626 $climate->info( '@' . $target . ' - [OK]' );
627 $filtered_targets[] = $target;
628 $pks[] = $user_resp;
629 $is_connected = true;
630 if ( ( $target != $targets[ count( $targets ) - 1 ] ) && ( count( $targets ) > 0 ) ) {
631 sleep( 1 );
632 }
633 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
634 sleep( 7 );
635 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
636 sleep( 7 );
637 } catch ( \InstagramAPI\Exception\ChallengeRequiredException $e ) {
638 $climate->error( 'Please login again and pass verification challenge. Instagram will send you a security code to verify your identity.' );
639 run( $ig, $climate );
640 } catch ( \InstagramAPI\Exception\CheckpointRequiredException $e ) {
641 $climate->error( 'Please go to Instagram website or mobile app and pass checkpoint!' );
642 run( $ig, $climate );
643 } catch ( \InstagramAPI\Exception\AccountDisabledException $e ) {
644 $climate->error( 'Your account has been disabled for violating Instagram terms. Go Instagram website or mobile app to learn how you may be able to restore your account.' );
645 $climate->error( 'Use this form for recovery your account: https://help.instagram.com/contact/1652567838289083' );
646 run( $ig, $climate );
647 } catch ( \InstagramAPI\Exception\ConsentRequiredException $e ) {
648 $climate->error( 'Instagram updated Terms and Data Policy. Please go to Instagram website or mobile app to review these changes and accept them.' );
649 run( $ig, $climate );
650 } catch ( \InstagramAPI\Exception\SentryBlockException $e ) {
651 $climate->error( 'Access to Instagram API restricted for spam behavior or otherwise abusing. You can try to use Session Catcher script (available by https://nextpost.tech/session-catcher) to get valid Instagram session from location, where your account created from.' );
652 run( $ig, $climate );
653 } catch ( \InstagramAPI\Exception\ThrottledException $e ) {
654 $climate->error( 'Throttled by Instagram because of too many API requests.' );
655 $climate->error( 'Please login again after 1 hour. You reached Instagram limits.' );
656 run( $ig, $climate );
657 } catch ( \InstagramAPI\Exception\NotFoundException $e ) {
658 $is_connected = true;
659 $is_username_correct = false;
660 do {
661 $climate->error( 'Instagram profile username @' . $target . ' is incorrect or maybe user just blocked you (Login to Instagram website or mobile app and check that).' );
662 $climate->error( 'Type 3 for skip this target.' );
663 $target_new = getVarFromUser( 'Please provide valid username' );
664
665 if ( empty( $target_new ) ) {
666 do {
667 $target_new = getVarFromUser( 'Please provide valid username' );
668 } while ( empty( $target_new ) );
669 }
670
671 if ( $target_new == '3' ) {
672 break;
673 } else {
674 $is_connected = false;
675 $is_connected_count = 0;
676 do {
677 if ( $is_connected_count == 10 ) {
678 if ( $e->getResponse() ) {
679 $climate->errorBold( $e->getMessage() );
680 }
681 $fail_message = "There is a problem with your Ethernet connection or Instagram is down at the moment. We couldn't establish connection with Instagram 10 times. Please try again later.";
682 $climate->errorBold( $fail_message );
683 run( $ig, $climate );
684 }
685
686 try {
687 $user_resp = $ig->people->getUserIdForName( $target_new );
688 $climate->info( '@' . $target_new . ' - [OK]' );
689 $filtered_targets[] = $target_new;
690 $pks[] = $user_resp;
691 $is_username_correct = true;
692 $is_connected = true;
693 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
694 sleep( 7 );
695 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
696 sleep( 7 );
697 } catch ( InstagramAPI\Exception\NotFoundException $e ) {
698 $is_username_correct = false;
699 $is_connected = true;
700 } catch ( \Exception $e ) {
701 $climate->error( $e->getMessage() );
702 run( $ig, $climate );
703 }
704 $is_connected_count += 1;
705 } while ( ! $is_connected );
706 }
707 } while ( ! $is_username_correct );
708 } catch ( Exception $e ) {
709 $climate->errorBold( $e->getMessage() );
710 run( $ig, $climate );
711 }
712
713 $is_connected_count += 1;
714 } while ( ! $is_connected );
715 }
716 } while ( empty( $filtered_targets ) );
717
718 $targets = array_unique( $filtered_targets );
719 $pks = array_unique( $pks );
720
721 $data_targ = [];
722 for ( $i = 0; $i < count( $targets ); $i++ ) {
723 $data_targ[ $i ] = [
724 'username' => $targets[ $i ],
725 'pk' => $pks[ $i ],
726 ];
727 }
728
729 $climate->info( 'Selected ' . count( $targets ) . ' targets: @' . implode( ', @', $targets ) . '.' );
730 $climate->info( 'Please confirm that the selected targets are correct.' );
731 $climate->info( '1 - [Yes]' );
732 $climate->info( '2 - [No]' );
733 $climate->info( '3 - [Exit]' );
734
735 $confirm = getVarFromUser( 'Choice' );
736
737 if ( empty( $confirm ) ) {
738 do {
739 $confirm = getVarFromUser( 'Choice' );
740 } while ( empty( $confirm ) );
741 }
742
743 if ( $confirm == '1' || $confirm == '2' || $confirm == '3' ) {
744 // All fine
745 } else {
746 $is_choice_ok = false;
747 do {
748 $climate->error( 'Choice is incorrect. Type 1, 2 or 3.' );
749 $confirm = getVarFromUser( 'Choice' );
750
751 if ( empty( $confirm ) ) {
752 do {
753 $confirm = getVarFromUser( 'Choice' );
754 } while ( empty( $confirm ) );
755 }
756
757 if ( $confirm == '1' || $confirm == '2' || $confirm == '3' ) {
758 $is_choice_ok = true;
759 }
760 } while ( ! $is_choice_ok );
761 }
762
763 if ( $confirm == '3' ) {
764 run( $ig, $climate );
765 } elseif ( $confirm == '2' ) {
766 $data_targ = define_targets( $ig, $defined_targets, $climate );
767 } else {
768 // All fine. Going to Hypervote.
769 }
770
771 return $data_targ;
772}
773
774/**
775 * Get varable from user
776 */
777function getVarFromUser( $text ) {
778 echo $text . ': ';
779 $var = trim( fgets( STDIN ) );
780 return $var;
781}
782
783/**
784 * Output message with data to console
785 */
786function output( $message ) {
787 echo '[', date( 'H:i:s' ), '] ', $message, PHP_EOL;
788}
789
790/**
791 * Output clean message to console
792 */
793function output_clean( $message ) {
794 echo $message, PHP_EOL;
795}
796
797/**
798 * Validates proxy address
799 */
800function isValidProxy( $proxy, $climate ) {
801 $climate->info( 'Connecting to Instagram...' );
802 $code = null;
803
804 try {
805 $client = new \GuzzleHttp\Client();
806 $res = $client->request(
807 'GET',
808 'http://www.instagram.com',
809 [
810 'timeout' => 60,
811 'proxy' => $proxy,
812 ]
813 );
814 $code = $res->getStatusCode();
815 $is_connected = true;
816 } catch ( \Exception $e ) {
817 //$climate->error( $e->getMessage() );
818 $code = '500';
819 //return false;
820 }
821
822 return $code;
823}
824
825/**
826 * Validates proxy address
827 */
828function finishLogin( $ig, $login, $password, $proxy, $climate ) {
829 $is_connected = false;
830 $is_connected_count = 0;
831
832 try {
833 do {
834 if ( $is_connected_count == 10 ) {
835 if ( $e->getResponse() ) {
836 $climate->out( $e->getMessage() );
837 }
838 $fail_message = "There is a problem with your Ethernet connection or Instagram is down at the moment. We couldn't establish connection with Instagram 10 times. Please try again later.";
839 $climate->errorBold( $fail_message );
840 run( $ig, $climate );
841 }
842
843 if ( $proxy == '3' ) {
844 // Skip proxy setup
845 } else {
846 $ig->setProxy( $proxy );
847 }
848
849 try {
850 $login_resp = $ig->login( $login, $password );
851
852 if ( $login_resp !== null && $login_resp->isTwoFactorRequired() ) {
853 // Default verification method is phone
854 $twofa_method = '1';
855
856 // Detect is Authentification app verification is available
857 $is_totp = json_decode( json_encode( $login_resp ), true );
858 if ( $is_totp['two_factor_info']['totp_two_factor_on'] == '1' ) {
859 $climate->info( 'Two-factor authentication required, please enter the code from you Authentication app' );
860 $twofa_id = $login_resp->getTwoFactorInfo()->getTwoFactorIdentifier();
861 $twofa_method = '3';
862 } else {
863 $climate->info(
864 'Two-factor authentication required, please enter the code sent to your number ending in %s',
865 $login_resp->getTwoFactorInfo()->getObfuscatedPhoneNumber()
866 );
867 $twofa_id = $login_resp->getTwoFactorInfo()->getTwoFactorIdentifier();
868 }
869
870 $twofa_code = getVarFromUser( 'Two-factor code' );
871
872 if ( empty( $twofa_code ) ) {
873 do {
874 $twofa_code = getVarFromUser( 'Two-factor code' );
875 } while ( empty( $twofa_code ) );
876 }
877
878 $is_connected = false;
879 $is_connected_count = 0;
880 do {
881 if ( $is_connected_count == 10 ) {
882 if ( $e->getResponse() ) {
883 $climate->errorBold( $e->getMessage() );
884 }
885 $climate->errorBold( $fail_message );
886 run( $ig, $climate );
887 }
888
889 if ( $is_connected_count == 0 ) {
890 $climate->info( 'Two-factor authentication in progress...' );
891 }
892
893 try {
894 $twofa_resp = $ig->finishTwoFactorLogin( $login, $password, $twofa_id, $twofa_code, $twofa_method );
895 $is_connected = true;
896 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
897 sleep( 7 );
898 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
899 sleep( 7 );
900 } catch ( \InstagramAPI\Exception\InvalidSmsCodeException $e ) {
901 $is_code_correct = false;
902 $is_connected = true;
903 do {
904 $cliate->errorBold( 'Code is incorrect. Please check the syntax and try again.' );
905 $twofa_code = getVarFromUser( 'Two-factor code' );
906
907 if ( empty( $twofa_code ) ) {
908 do {
909 $twofa_code = getVarFromUser( 'Security code' );
910 } while ( empty( $twofa_code ) );
911 }
912
913 $is_connected = false;
914 $is_connected_count = 0;
915 do {
916 try {
917 if ( $is_connected_count == 10 ) {
918 if ( $e->getResponse() ) {
919 $climate->error( $e->getMessage() );
920 }
921 $climate->errorBold( $fail_message );
922 run( $ig, $climate );
923 }
924
925 if ( $is_connected_count == 0 ) {
926 $climate->info( 'Verification in progress...' );
927 }
928 $twofa_resp = $ig->finishTwoFactorLogin( $login, $password, $twofa_id, $twofa_code, $twofa_method );
929 $is_code_correct = true;
930 $is_connected = true;
931 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
932 sleep( 7 );
933 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
934 sleep( 7 );
935 } catch ( \InstagramAPI\Exception\InvalidSmsCodeException $e ) {
936 $is_code_correct = false;
937 $is_connected = true;
938 } catch ( \Exception $e ) {
939 throw new $e();
940 }
941 $is_connected_count += 1;
942 } while ( ! $is_connected );
943 } while ( ! $is_code_correct );
944 } catch ( \Exception $e ) {
945 throw $e;
946 }
947
948 $is_connected_count += 1;
949 } while ( ! $is_connected );
950 }
951
952 $is_connected = true;
953 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
954 sleep( 7 );
955 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
956 sleep( 7 );
957 } catch ( \InstagramAPI\Exception\CheckpointRequiredException $e ) {
958 throw new Exception( 'Please go to Instagram website or mobile app and pass checkpoint!' );
959 } catch ( \InstagramAPI\Exception\ChallengeRequiredException $e ) {
960 $climate->error( 'Instagram Response: ' . json_encode( $e->getResponse() ) );
961 $climate->error( "Couldn't complete the verification challenge. Please try again later." );
962 throw new Exception( 'Developer code: Challenge loop.' );
963 } catch ( \Exception $e ) {
964 throw $e;
965 }
966
967 $is_connected_count += 1;
968 } while ( ! $is_connected );
969 } catch ( \Exception $e ) {
970 $climate->errorBold( $e->getMessage() );
971 run( $ig, $climate );
972 }
973
974 return $ig;
975}
976
977/**
978 * Verification challenge
979 */
980function challange( $ig, $login, $password, $api_path, $security_code, $proxy, $climate ) {
981 $is_connected = false;
982 $is_connected_count = 0;
983 $fail_message = "There is a problem with your Ethernet connection or Instagram is down at the moment. We couldn't establish connection with Instagram 10 times. Please try again later.";
984
985 do {
986 if ( $is_connected_count == 10 ) {
987 if ( $e->getResponse() ) {
988 $climate->errorBold( $e->getMessage() );
989 }
990 throw new Exception( $fail_message );
991 }
992
993 if ( $is_connected_count == 0 ) {
994 $climate->info( 'Verification in progress...' );
995 }
996
997 try {
998 $challenge_resp = $ig->finishChallengeLogin( $login, $password, $api_path, $security_code );
999 $is_connected = true;
1000 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
1001 sleep( 7 );
1002 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
1003 sleep( 7 );
1004 } catch ( \InstagramAPI\Exception\InstagramException $e ) {
1005
1006 $msg = $e->getMessage();
1007 $climate->out( $msg );
1008
1009 $climate->out( 'Type 3 - to exit.' );
1010
1011 $security_code = getVarFromUser( 'Security code' );
1012
1013 if ( empty( $security_code ) ) {
1014 do {
1015 $security_code = getVarFromUser( 'Security code' );
1016 } while ( empty( $security_code ) );
1017 }
1018
1019 if ( $security_code == '3' ) {
1020 throw new Exception( 'Reset in progress...' );
1021 }
1022 } catch ( \Exception $e ) {
1023 $msg = $e->getMessage();
1024 if ( $msg == 'Invalid Login Response at finishChallengeLogin().' ) {
1025 sleep( 7 );
1026 $ig = finishLogin( $ig, $login, $password, $proxy, $climate );
1027 $is_connected = true;
1028 } else {
1029 throw $e;
1030 }
1031 }
1032
1033 $is_connected_count += 1;
1034 } while ( ! $is_connected );
1035
1036 return $ig;
1037}
1038
1039/**
1040 * Hypervote loop - Algorithm #2
1041 */
1042function hypervote_v1( $data, $data_targ, $ig, $delay, $fresh_stories_range, $climate ) {
1043
1044 $view_count = 0;
1045 $st_count = 0;
1046 $st_count_seen = 0;
1047 $begin = strtotime( date( 'Y-m-d H:i:s' ) );
1048 $begin_ms = strtotime( date( 'Y-m-d H:i:s' ) );
1049 $begin_f = strtotime( date( 'Y-m-d H:i:s' ) );
1050 $speed = 0;
1051 $delitel = 0;
1052 $counter1 = 0;
1053 $counter2 = 0;
1054 $stories = [];
1055 $mycount = 0;
1056 $poll_votes_count = 0;
1057 $slider_points_count = 0;
1058
1059 $climate->infoBold( 'Hypervote loop started.' );
1060
1061 $targets = [];
1062 $targets = $data_targ;
1063
1064 for ( $i = 0; $i < count( $data_targ ); $i++ ) {
1065 $data_targ[ $i ] += [
1066 'rank_token' => \InstagramAPI\Signatures::generateUUID(),
1067 'users_count' => 0,
1068 'max_id' => null,
1069 'begin_gf' => null,
1070 ];
1071 }
1072
1073 do {
1074 foreach ( $data_targ as $key => $d ) {
1075 try {
1076 if ( $d['max_id'] == null ) {
1077 $is_gf_first = 1;
1078 }
1079
1080 if ( ! empty( $d['begin_gf'] ) ) {
1081 $current_time = strtotime( date( 'Y-m-d H:i:s' ) );
1082 if ( ( $current_time - $d['begin_gf'] ) < 7 ) {
1083 $sleep_time = 7 - ( $current_time - $d['begin_gf'] );
1084 sleep( $sleep_time );
1085 }
1086 }
1087
1088 try {
1089 $data_targ[ $key ]['begin_gf'] = strtotime( date( 'Y-m-d H:i:s' ) );
1090 $followers = $ig->people->getFollowers( $d['pk'], $d['rank_token'], null, $d['max_id'] );
1091 } catch ( \InstagramAPI\Exception\NotFoundException $e ) {
1092 $climate->error( '@' . $d['username'] . ' not found or maybe user blocked you (login to Instagram website or mobile app and check that).' );
1093 unset( $data_targ[ $key ] );
1094 continue;
1095 } catch ( Exception $e ) {
1096 throw $e;
1097 }
1098
1099 // DEBUG - BEGIN
1100 //$followers_json = json_decode($followers);
1101 // output(var_dump($followers_json));
1102 // exit;
1103 // DEBUG - END
1104
1105 if ( empty( $followers->getUsers() ) ) {
1106 $climate->error( '@' . $d['username'] . " don't have any follower." );
1107 unset( $data_targ[ $key ] );
1108 continue;
1109 }
1110
1111 $follos = json_decode( $followers, true );
1112
1113 //output(print_r($follos['users'],true));
1114
1115 $data_targ[ $key ]['max_id'] = $follos['next_max_id'];
1116
1117 $followers_ids = [];
1118 foreach ( $follos['users'] as $follower ) {
1119 // Skip private accounts, accounts with anonymous profile picture and verified accounts
1120 // Check is user have stories at scrapping
1121 /*if ((1 !==$follower['is_private'])
1122 && !($follower['has_anonymous_profile_picture'])
1123 && !($follower['is_verified'])
1124 && (0 !== $follower['latest_reel_media'])) {
1125 if (isset($fresh_stories_range)) {
1126 $fresh_stories_min = date("Y-m-d H:i:s", time() - (int)$fresh_stories_range*60*60);
1127 if ($follower['latest_reel_media'] >= strtotime($fresh_stories_min)) {
1128 $followers_ids[] = $follower['pk'];
1129 }
1130 } else {*/
1131 // Check is latest
1132 $followers_ids[] = $follower['pk'];
1133 /*}*/
1134 /*}*/
1135 }
1136
1137 // Re-indexing array
1138 $followers_ids = array_values( $followers_ids );
1139
1140 $data_targ[ $key ]['users_count'] = $d['users_count'] + count( $followers_ids );
1141
1142 $number = count( $followers_ids );
1143
1144 if ( $is_gf_first ) {
1145 $climate->info( $number . ' followers of @' . $d['username'] . ' collected.' );
1146 $is_gf_first = 0;
1147 } else {
1148 $climate->info( 'Next ' . $number . ' followers of @' . $d['username'] . ' collected. Total: ' . number_format( $data_targ[ $key ]['users_count'], 0, '.', ' ' ) . ' followers of @' . $d['username'] . ' parsed.' );
1149 }
1150
1151 $index_new = 0;
1152 $index_old = 0;
1153
1154 do {
1155 $index_new += 13;
1156
1157 if ( ! isset( $followers_ids[ $index_new ] ) ) {
1158 do {
1159 $index_new -= 1;
1160 } while ( ! isset( $followers_ids[ $index_new ] ) );
1161 }
1162
1163 if ( $index_new < $index_old ) {
1164 break;
1165 }
1166
1167 $ids = [];
1168 for ( $i = $index_old; $i <= $index_new; $i++ ) {
1169 if ( isset( $followers_ids[ $i ] ) ) {
1170 $ids[] = $followers_ids[ $i ];
1171 }
1172 }
1173
1174 try {
1175 try {
1176 $stories_reels = $ig->story->getReelsMediaFeed( $ids );
1177 } catch ( \InstagramAPI\Exception\BadRequestException $e ) {
1178 // Invalid reel id list.
1179 // That's mean that this users don't have stories.
1180 } catch ( Exception $e ) {
1181 throw $e;
1182 }
1183
1184 $counter1 += 1;
1185
1186 if ( isset( $stories_reels ) && $stories_reels->isOk() && count( $stories_reels->getReels()->getData() ) > 0 ) {
1187 // Save user story reels's to array
1188 $reels = [];
1189 $reels = $stories_reels->getReels()->getData();
1190
1191 foreach ( $reels as $r ) {
1192 $items = [];
1193 $stories_loop = [];
1194 $items = $r->getItems();
1195
1196 foreach ( $items as $item ) {
1197 if ( ! $item->getId() ) {
1198 // Item is not valid
1199 continue;
1200 }
1201 $it = json_decode( $item, true );
1202
1203 if ( array_key_exists( 'story_polls', $it ) ) {
1204 if ( ! $data->is_poll_vote_active ) {
1205 continue;
1206 }
1207
1208 if ( isset( $it['story_polls'][0]['poll_sticker']['viewer_vote'] ) ) {
1209 continue;
1210 }
1211 try {
1212 $oy = mt_rand( 0, 1 );
1213 $ig->story->votePollStory( $it['id'], $it['story_polls'][0]['poll_sticker']['poll_id'], $oy );
1214 } catch (\InstagramAPI\Exception\BadRequestException $e) {
1215 sleep(3);
1216 } catch ( Exception $e ) {
1217 //throw $e;
1218 continue;
1219 }
1220
1221
1222 $poll_votes_count++;
1223 $mycount++;
1224 $stories_loop[] = $item;
1225 $climate->magenta( 'Poll Voted : ' . $oy . ' Votes Given: ' . $poll_votes_count . ' Total : ' . $mycount );
1226 } elseif ( array_key_exists( 'story_sliders', $it ) ) {
1227 if ( ! $data->is_slider_points_active ) {
1228 continue;
1229 }
1230
1231 if ( isset( $it['story_sliders'][0]['slider_sticker']['viewer_vote'] ) ) {
1232 continue;
1233 }
1234 try{
1235 $point = ( mt_rand( $data->slider_points_range[0], $data->slider_points_range[1] ) / 100 );
1236 $ig->story->voteSliderStory( $it['id'], $it['story_sliders'][0]['slider_sticker']['slider_id'], $point );
1237 } catch (\InstagramAPI\Exception\BadRequestException $e) {
1238 sleep(3);
1239 } catch ( Exception $e ) {
1240 //throw $e;
1241 continue;
1242 }
1243
1244
1245 $slider_points_count++;
1246 $mycount++;
1247 $stories_loop[] = $item;
1248 $climate->blue( 'Slider point given : ' . $point . ' Given points: ' . $slider_points_count . ' Total : ' . $mycount );
1249 } elseif ( array_key_exists( 'story_questions', $it ) ) {
1250 if ( ! $data->is_questions_answers_active ) {
1251 continue;
1252 }
1253 if ( ! $it['can_reply'] ) {
1254 continue;
1255 }
1256 $questions = $data->questions_answers;
1257 $real_respond = $questions[ mt_rand( 0, ( count( $questions ) - 1 ) ) ];
1258 try {
1259 $ig->story->answerStoryQuestion( $it['id'], $it['story_questions'][0]['question_sticker']['question_id'], $real_respond );
1260 $mycount++;
1261 $stories_loop[] = $item;
1262 $climate->yellow( 'Question Answered: ' . $real_respond . ' Total : ' . $mycount );
1263 } catch (\InstagramAPI\Exception\BadRequestException $e) {
1264 sleep(3);
1265 } catch ( \Exception $e ) {
1266 continue;
1267 }
1268 } elseif ( array_key_exists( 'story_quizs', $it ) ) {
1269 if ( ! $data->is_quiz_answers_active ) {
1270 continue;
1271 }
1272
1273 if ( isset( $it['story_quizs'][0]['quiz_sticker']['viewer_answer'] ) ) {
1274 continue;
1275 }
1276
1277 // Generate vote and complete quiz
1278 $answer_1 = isset( $it['story_quizs'][0]['quiz_sticker']['tallies'][0] ) ? 1 : 0;
1279 $answer_2 = isset( $it['story_quizs'][0]['quiz_sticker']['tallies'][1] ) ? 1 : 0;
1280 $answer_3 = isset( $it['story_quizs'][0]['quiz_sticker']['tallies'][2] ) ? 1 : 0;
1281 $answer_4 = isset( $it['story_quizs'][0]['quiz_sticker']['tallies'][3] ) ? 1 : 0;
1282
1283 if ( $answer_1 && $answer_2 && $answer_3 && $answer_4 ) {
1284 $vote = mt_rand( 0, 3 );
1285 } elseif ( $answer_1 && $answer_2 && $answer_3 ) {
1286 $vote = mt_rand( 0, 2 );
1287 } elseif ( $answer_1 && $answer_2 ) {
1288 $vote = mt_rand( 0, 1 );
1289 }
1290
1291 try {
1292 $ig->story->voteQuizStory( $it['pk'], $it['story_quizs'][0]['quiz_sticker']['quiz_id'], $vote );
1293 $mycount++;
1294 $stories_loop[] = $item;
1295 $climate->lightGray( 'Quiz Answered: ' . $vote . ' Total : ' . $mycount );
1296
1297 } catch (\InstagramAPI\Exception\BadRequestException $e) {
1298 sleep(3);
1299 } catch ( Exception $e ) {
1300 //throw $e;
1301 continue;
1302 }
1303 } else {
1304 $stories_loop[] = $item;
1305 }
1306 }
1307
1308 if ( empty( $stories ) ) {
1309 $stories = $stories_loop;
1310 } else {
1311 $stories = array_merge( $stories, $stories_loop );
1312 }
1313
1314 $st_count = $st_count + count( $stories_loop );
1315 $view_count = $view_count + count( $stories_loop );
1316
1317 $now = strtotime( date( 'Y-m-d H:i:s' ) );
1318 if ( $now - $begin > 299 ) {
1319 $begin = strtotime( date( 'Y-m-d H:i:s' ) );
1320 $delitel = $delitel + 1;
1321 $speed = (int) ( $view_count * 12 * 24 / $delitel );
1322 output_clean( '' );
1323 output_clean( 'Estimated speed is ' . number_format( $speed, 0, '.', ' ' ) . ' stories/day.' );
1324 output_clean( '© Hypervote Terminal. With 3 Hours fresh stories, you can gain more follower..' );
1325 output_clean( '' );
1326 }
1327
1328 $now_f = strtotime( date( 'Y-m-d H:i:s' ) );
1329 if ( $now_f - $begin_f > 1 ) {
1330 $begin_f = strtotime( date( 'Y-m-d H:i:s' ) );
1331 // output($st_count . " stories found. / Debug: getReelsMediaFeed (" . $counter1 . "), markMediaSeen (" . $counter2 . ")");
1332 //output($st_count . " stories found.");
1333 }
1334
1335 if ( $st_count % 1000 == 0 ) {
1336 // output($st_count . " stories found. / Debug: getReelsMediaFeed (" . $counter1 . "), markMediaSeen (" . $counter2 . ")");
1337 /// output($st_count . " stories found.");
1338
1339 $now_ms = strtotime( date( 'Y-m-d H:i:s' ) );
1340 if ( $now_ms - $begin_ms >= $delay ) {
1341 // all fine
1342 } else {
1343 $counter3 = $delay - ( $now_ms - $begin_ms );
1344 $climate->darkGray( 'Starting ' . $counter3 . ' second(s) delay for bypassing Instagram limits.' );
1345 do {
1346 $climate->darkGray( $counter3 . ' second(s) left.' );
1347 sleep( 1 );
1348 $counter3 -= 1;
1349 } while ( $counter3 != 0 );
1350 }
1351
1352 // Mark collected stories as seen
1353 // $mark_seen_resp = $ig->story->markMediaSeen($stories);
1354 //$begin_ms = strtotime(date("Y-m-d H:i:s"));
1355
1356 // $st_count_seen = number_format($st_count, 0, '.', ' ');
1357 // $counter2 += 1;
1358 // output($st_count_seen . " stories marked as seen. / Debug: getReelsMediaFeed (" . $counter1 . "), markMediaSeen (" . $counter2 . ").");
1359 // output($st_count_seen . " stories marked as seen.");
1360
1361 }
1362 }
1363 }
1364
1365 // if (($st_count > 0) && $data[$key]['max_id'] == null) {
1366 // Mark collected stories as seen
1367 // $mark_seen_resp = $ig->story->markMediaSeen($stories);
1368
1369 // $st_count_seen = number_format($st_count, 0, '.', ' ');
1370 // $counter2 += 1;
1371 // output($st_count_seen . " stories marked as seen. / Debug: getReelsMediaFeed (" . $counter1 . "), markMediaSeen (" . $counter2 . ").");
1372 // output($st_count_seen . " stories marked voted.");
1373 // output_clean("");
1374 // output_clean("Total: " . number_format($view_count, 0, '.', ' ') . " stories successfully seen.");
1375 // output_clean("");
1376
1377 // Initialize arrays and parameters again
1378 //$stories = [];
1379 //$st_count = 0;
1380 //}
1381
1382 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
1383 $climate->error( "We couldn't connect to Instagram at the moment. Trying again." );
1384 sleep( 7 );
1385 $index_new -= 13;
1386 continue;
1387 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
1388 $climate->error( 'Instagram sent us empty response. Trying again.' );
1389 sleep( 7 );
1390 $index_new -= 13;
1391 continue;
1392 } catch ( \InstagramAPI\Exception\LoginRequiredException $e ) {
1393 $climate->error( 'Please login again to your Instagram account. Login required.' );
1394 run( $ig, $climate );
1395 } catch ( \InstagramAPI\Exception\ChallengeRequiredException $e ) {
1396 $climate->error( 'Please login again and pass verification challenge. Instagram will send you a security code to verify your identity.' );
1397 run( $ig, $climate );
1398 } catch ( \InstagramAPI\Exception\CheckpointRequiredException $e ) {
1399 $climate->error( 'Please go to Instagram website or mobile app and pass checkpoint!' );
1400 run( $ig, $climate );
1401 } catch ( \InstagramAPI\Exception\AccountDisabledException $e ) {
1402 $climate->error( 'Your account has been disabled for violating Instagram terms. Go Instagram website or mobile app to learn how you may be able to restore your account.' );
1403 $climate->error( 'Use this form for recovery your account: https://help.instagram.com/contact/1652567838289083' );
1404 run( $ig, $climate );
1405 } catch ( \InstagramAPI\Exception\ConsentRequiredException $e ) {
1406 $climate->error( 'Instagram updated Terms and Data Policy. Please go to Instagram website or mobile app to review these changes and accept them.' );
1407 run( $ig, $climate );
1408 } catch ( \InstagramAPI\Exception\SentryBlockException $e ) {
1409 $climate->error( 'Access to Instagram API restricted for spam behavior or otherwise abusing.' );
1410 run( $ig, $climate );
1411 } catch ( \InstagramAPI\Exception\ThrottledException $e ) {
1412 $climate->error( 'Throttled by Instagram because of too many API requests.' );
1413 $climate->error( '12 hours rest for account started because you reached Instagram daily limit for Hypervote.' );
1414 sleep( 43200 );
1415 } catch ( Exception $e ) {
1416 $climate->error( $e->getMessage() );
1417 sleep( 7 );
1418 }
1419
1420 $index_old = $index_new + 1;
1421
1422 } while ( $data_targ[ $key ]['max_id'] != null );
1423
1424 // Check is $max_id is null
1425 if ( $data_targ[ $key ]['max_id'] == null ) {
1426 $climate->blue( 'All stories of @' . $d['username'] . "'s followers successfully Voted." );
1427 unset( $data_targ[ $key ] );
1428 continue;
1429 }
1430
1431 /*if($view_count >= 14900){
1432 $generated_password = randomPassword();
1433 $change_password = $ig->account->changePassword($password,$generated_password);
1434 output_clean("New Password: ".$generated_password);
1435 }*/
1436
1437 } catch ( \InstagramAPI\Exception\NetworkException $e ) {
1438 sleep( 7 );
1439 } catch ( \InstagramAPI\Exception\EmptyResponseException $e ) {
1440 sleep( 7 );
1441 } catch ( \InstagramAPI\Exception\LoginRequiredException $e ) {
1442 $climate->error( 'Please login again to your Instagram account. Login required.' );
1443 run( $ig, $climate );
1444 } catch ( \InstagramAPI\Exception\ChallengeRequiredException $e ) {
1445 $climate->error( 'Please login again and pass verification challenge. Instagram will send you a security code to verify your identity.' );
1446 run( $ig, $climate );
1447 } catch ( \InstagramAPI\Exception\CheckpointRequiredException $e ) {
1448 $climate->error( 'Please go to Instagram website or mobile app and pass checkpoint!' );
1449 run( $ig, $climate );
1450 } catch ( \InstagramAPI\Exception\AccountDisabledException $e ) {
1451 $climate->error( 'Your account has been disabled for violating Instagram terms. Go Instagram website or mobile app to learn how you may be able to restore your account.' );
1452 $climate->error( 'Use this form for recovery your account: https://help.instagram.com/contact/1652567838289083' );
1453 run( $ig, $climate );
1454 } catch ( \InstagramAPI\Exception\ConsentRequiredException $e ) {
1455 $climate->error( 'Instagram updated Terms and Data Policy. Please go to Instagram website or mobile app to review these changes and accept them.' );
1456 run( $ig, $climate );
1457 } catch ( \InstagramAPI\Exception\SentryBlockException $e ) {
1458 $climate->error( 'Access to Instagram API restricted for spam behavior or otherwise abusing. You can try to use Session Catcher script (available by https://nextpost.tech/session-catcher) to get valid Instagram session from location, where your account created from.' );
1459 run( $ig, $climate );
1460 } catch ( \InstagramAPI\Exception\ThrottledException $e ) {
1461 $climate->error( 'Throttled by Instagram because of too many API requests.' );
1462 $climate->error( '12 hours rest for account started because you reached Instagram daily limit for Hypervote.' );
1463 sleep( 43200 );
1464 } catch ( Exception $e ) {
1465 $climate->errorBold( $e->getMessage() );
1466 sleep( 7 );
1467 }
1468 }
1469 } while ( ! empty( $data_targ ) );
1470
1471 $climate->blue( 'All stories related to the targets seen. Starting the new loop.' );
1472 $climate->blue( '' );
1473
1474 hypervote_v1( $data, $targets, $ig, $delay, $fresh_stories_range, $climate );
1475}
1476
1477
1478
1479/**
1480 * Generate Random Password
1481 *
1482 */
1483
1484
1485
1486/**
1487 * Send request
1488 * @param $url
1489 * @return mixed
1490 */
1491function request( $url ) {
1492 $ch = curl_init();
1493
1494 curl_setopt( $ch, CURLOPT_URL, $url );
1495 curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
1496 curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
1497 curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
1498
1499 $return = curl_exec( $ch );
1500
1501 curl_close( $ch );
1502
1503 return $return;
1504}