Skip to content

Commit

Permalink
1.0.6
Browse files Browse the repository at this point in the history
- Giriş sorunu düzeltildi
- Kullanıcı profil resmi değiştirme eklendi
  • Loading branch information
Hasokeyk committed Mar 14, 2021
1 parent 1936ec8 commit 6179f49
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor/
index.php
src/cache/*/
assets/
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"license": "MIT",
"minimum-stability": "stable",
"require": {
"guzzlehttp/guzzle":"^7.0.1"
},
"require": {
"guzzlehttp/guzzle":"^7.0.1",
"php": ">=7.0.0"
},
"autoload": {
Expand Down
18 changes: 10 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions examples/instagram-user-change-profil-pic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use instagram\instagram;

require "vendor/autoload.php";

$username = 'username';
$password = 'password';

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

$login = $instagram->login->login_control();
if($login){

$pic_path = __DIR__.'/filename.jpg';
$change_profil_pic = $instagram->user->change_profil_pic($pic_path);
if($change_profil_pic){
echo 'Changed';
}else{
echo 'Not changed';
}

}else{
echo 'Login Fail';
}
1 change: 0 additions & 1 deletion examples/instagram-user-get-posts-statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use instagram\instagram;

require "vendor/autoload.php";
//require "src/instagram.php";

$username = 'username';
$password = 'password';
Expand Down
1 change: 0 additions & 1 deletion examples/instagram-user-get-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use instagram\instagram;

require "vendor/autoload.php";
//require "src/instagram.php";

$username = 'username';
$password = 'password';
Expand Down
1 change: 0 additions & 1 deletion examples/instagram-user-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use instagram\instagram;

require "vendor/autoload.php";
//require "src/instagram.php";

$username = 'username';
$password = 'password';
Expand Down
5 changes: 4 additions & 1 deletion src/instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require "instagram_login.php";
require "instagram_user.php";
require "instagram_statistics.php";
require "instagram_upload.php";

class instagram{

Expand All @@ -22,12 +23,14 @@ function __construct($username = null, $password = null){
'login' => new instagram_login($username, $password, $this->functions),
'statistics' => new instagram_statistics($username, $password, $this->functions),
'user' => new instagram_user($username, $password, $this->functions),
'upload' => new instagram_upload($username, $password, $this->functions),
];

$this->request = new instagram_request($username, $password, $this->functions);
$this->login = new instagram_login($username, $password, $this->functions);
$this->user = new instagram_user($username, $password, $this->functions);
$this->statistics = new instagram_statistics($username, $password, $this->functions);
$this->upload = new instagram_upload($username, $password, $this->functions);

}

Expand Down
105 changes: 95 additions & 10 deletions src/instagram_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,59 @@ function __construct($username, $password, $functions = null){
$this->functions = $functions;
}

public function login2($username = null, $password = null){

$username = $username??$this->username;
$password = $password??$this->password;
$password = $this->encrypt($password);
$this->username = $username;

$url = 'https://i.instagram.com/api/v1/accounts/login/';

$post_data = [
'phone_id' => "832f3947-2366-42c7-a49e-88136c36f7ad",
'enc_password' => $password,
'_csrftoken' => 'YBck6oCPqG3e2YtLRxeiebBfVQawQm04',
'username' => $username,
'adid' => "f5904e04-349a-48ca-8516-8555ae99660c",
'guid' => "f1c270c3-8663-40ef-8612-3dc8853b3459",
'device_id' => "android-daa21d4b02905ea0",
'google_tokens' => '[]',
'login_attempt_count' => '0',
];
$post_data = ['signed_body' => (string) 'SIGNATURE.{"username":"hayatikodla"}'];

$header = [
'User-Agent' => 'Instagram 177.0.0.30.119 Android (22/5.1.1; 160dpi; 540x960; Google/google; google Pixel 2; x86; qcom; tr_TR; 276028050)',
];

$cookie = [
'mid' => 'YB2r4AABAAERcl5ESNxLjr_tt4Q5',
'csrftoken' => 'YBck6oCPqG3e2YtLRxeiebBfVQawQm04',
];

/*
$client = new \GuzzleHttp\Client([
'verify' => false,
'headers' => $header
]);
$result = $client->post($url,
[
'form_params' => $post_data
]
);
*/

$result = $this->request($url, 'POST', $post_data, $header);
print_r($result);

}

public function login($username = null, $password = null){

$username = $username??$this->username;
$password = $password??$this->password;
$username = $username??$this->username;
$password = $password??$this->password;
$this->username = $username;

$cookie = $this->cache($username.'-sessionid');
Expand All @@ -39,7 +88,13 @@ public function login($username = null, $password = null){
'login_attempt_count' => '0',
];
$post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)];
$result = $this->request($url, 'POST', $post_data);

$cookie = [
'mid' => 'YB2r4AABAAERcl5ESNxLjr_tt4Q5',
'csrftoken' => $this->get_csrftoken(),
];

$result = $this->request($url, 'POST', $post_data, null, $cookie);
return $this->login_check($result);

}
Expand Down Expand Up @@ -76,8 +131,7 @@ public function login_control($username = null){

try{

$url = 'https://i.instagram.com/api/v1/direct_v2/get_presence/';

$url = 'https://i.instagram.com/api/v1/direct_v2/get_presence/';
$result = $this->request($url);
$result_body = json_decode($result['body']);
if($result_body->status == 'ok'){
Expand All @@ -102,14 +156,12 @@ private function encrypt($password){
$iv = openssl_random_pseudo_bytes(12);
$time = time();

//$pubKey = openssl_pkey_get_public(Constants::IG_LOGIN_DEFAULT_ANDROID_PUBLIC_KEY);

openssl_public_encrypt($key, $encryptedAesKey, base64_decode($public_key));
$encrypted = openssl_encrypt($password, 'aes-256-gcm', $key, OPENSSL_RAW_DATA, $iv, $tag, strval($time));

$payload = base64_encode("\x01" | pack('n', intval($public_key_id)).$iv.pack('s', strlen($encryptedAesKey)).$encryptedAesKey.$tag.$encrypted);

return sprintf('#PWD_INSTAGRAM:4:%s:%s', $time, $payload);
return sprintf('#PWD_INSTAGRAM:4:%s:%s', $time, ($payload));

}

Expand All @@ -120,7 +172,7 @@ public function get_sync(){

$url = 'https://i.instagram.com/api/v1/qe/sync/';
$post_data = [
'_csrftoken' => 'khugUa357Qq939C5NQ2fReWGZXUraEzZ',
'_csrftoken' => $this->get_csrftoken(),
'id' => 'F2CD7326-EA40-44F8-9FC3-71A0A5E1F55B',
'server_config_retrieval' => '1',
'experiments' => "ig_growth_android_profile_pic_prefill_with_fb_pic_2,ig_account_identity_logged_out_signals_global_holdout_universe,ig_android_caption_typeahead_fix_on_o_universe,ig_android_retry_create_account_universe,ig_android_gmail_oauth_in_reg,ig_android_quickcapture_keep_screen_on,ig_android_smartlock_hints_universe,ig_android_reg_modularization_universe,ig_android_login_identifier_fuzzy_match,ig_android_passwordless_account_password_creation_universe,ig_android_security_intent_switchoff,ig_android_sim_info_upload,ig_android_device_verification_fb_signup,ig_android_reg_nux_headers_cleanup_universe,ig_android_direct_main_tab_universe_v2,ig_android_nux_add_email_device,ig_android_fb_account_linking_sampling_freq_universe,ig_android_device_info_foreground_reporting,ig_android_suma_landing_page,ig_android_device_verification_separate_endpoint,ig_android_direct_add_direct_to_android_native_photo_share_sheet,ig_android_device_detection_info_upload,ig_android_device_based_country_verification",
Expand All @@ -132,13 +184,46 @@ public function get_sync(){
'DEBUG-IG-USER-ID' => 0,
'Host' => 'i.instagram.com',
];
$res = $this->request($url, 'POST', $post_data, $headers);
$res = $this->request($url, 'POST', $post_data, $headers, null, false);

$result = (object) [
'pub_key_id' => $res['headers']['ig-set-password-encryption-key-id'][0],
'pub_key' => $res['headers']['ig-set-password-encryption-pub-key'][0],
];
$this->cache('app-key', $result);
//$this->get_launcher_sync();
}
else{
$result = $keys;
}
return $result;
}

public function get_launcher_sync(){

$keys = $this->cache('app_key');
if($keys == false){

$url = 'https://i.instagram.com/api/v1/launcher/sync/';
$post_data = [
'_csrftoken' => 'khugUa357Qq939C5NQ2fReWGZXUraEzZ',
'id' => 'F2CD7326-EA40-44F8-9FC3-71A0A5E1F55B',
'server_config_retrieval' => '1',
];
$post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)];

$headers = [
'User-Agent' => $this->user_agent,
'DEBUG-IG-USER-ID' => 0,
'Host' => 'i.instagram.com',
];
$res = $this->request($url, 'POST', $post_data, $headers, null, false);

$result = (object) [
'pub_key_id' => $res['headers']['ig-set-password-encryption-key-id'][0],
'pub_key' => $res['headers']['ig-set-password-encryption-pub-key'][0],
];
$this->cache('launcheR_sync', $result);

}
else{
Expand Down
Loading

0 comments on commit 6179f49

Please sign in to comment.