Skip to content

Commit

Permalink
1.0.36
Browse files Browse the repository at this point in the history
- Login sorunu giderildi
- Proxy sorunu giderildi
  • Loading branch information
Hasokeyk committed Dec 10, 2022
1 parent 8dee692 commit 55a72ae
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
12 changes: 6 additions & 6 deletions src/Instagram/InstagramLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function login($username = null, $password = null){
$url = $this->intagram_api_url.'/api/v1/accounts/login/';
$password = $this->encrypt($password);
$post_data = [
'jazoest' => '22453',
'jazoest' => '22522',
'country_codes' => '[{"country_code":"90","source":["sim","network","default","sim"]}]',
'phone_id' => $this->get_phone_id(),
'enc_password' => $password,
Expand All @@ -44,12 +44,12 @@ public function login($username = null, $password = null){
];
$post_data = ['signed_body' => 'SIGNATURE.'.json_encode($post_data)];

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

$result = $this->post($url, $post_data, $this->headers, $cookie);
$result = $this->post($url, $post_data, $this->headers);
return $this->login_check($result);

}
Expand Down
22 changes: 16 additions & 6 deletions src/Instagram/InstagramRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ class InstagramRequest{
public $cache_path = (__DIR__).'/../cache/';
public $cache_time = 10; //Minute

public $proxy = 'http://185.122.200.168:8118';
public $proxy = '';
public $client;
public $headers = [];
private $app_id = '567067343352427';
private $device_id;
private $phone_id = '01ec3ad7-f01e-4b4f-ba81-26ad8a444582';
private $guid;
private $adid;
public $user_agent = 'Instagram 219.0.0.12.117 Android (25/7.1.2; 320dpi; 900x1600; xiaomi; Redmi Note 8 Pro; d2q; qcom; tr_TR; 346138365)';
// public $user_agent = 'Instagram 219.0.0.12.117 Android (25/7.1.2; 320dpi; 900x1600; xiaomi; Redmi Note 8 Pro; d2q; qcom; tr_TR; 346138365)';
public $user_agent = 'Instagram 257.1.0.13.119 (iPhone14,3; iOS 16_1; tr_TR; tr-TR; scale=3.00; 1284x2778; 409247554) AppleWebKit/420+';

function __construct($username, $password, $functions){
$this->username = $username;
Expand Down Expand Up @@ -85,7 +86,7 @@ public function ready_header($user_cookie = false){
return $headers;
}

public function get($url = '', $headers = null, $cookie = true){
public function get($url = '', $headers = null, $cookie = true, $proxy_use = true){
try{
$headers = $headers ?? $this->ready_header();
$options = [
Expand All @@ -96,6 +97,10 @@ public function get($url = '', $headers = null, $cookie = true){
]
];

if(isset($this->proxy) and !empty($this->proxy) and $proxy_use === true){
$options['proxy'] = $this->proxy;
}

$res = $this->client->get($url, $options);
return [
'status' => 'ok',
Expand All @@ -113,7 +118,7 @@ public function get($url = '', $headers = null, $cookie = true){
}
}

public function post($url = null, $post_data = null, $headers = null){
public function post($url = null, $post_data = null, $headers = null, $proxy_use = true){
try{

$headers = $headers ?? $this->ready_header();
Expand All @@ -126,6 +131,10 @@ public function post($url = null, $post_data = null, $headers = null){
]
];

if(isset($this->proxy) and !empty($this->proxy) and $proxy_use === true){
$options['proxy'] = $this->proxy;
}

$res = $this->client->post($url, $options);
return [
'status' => 'ok',
Expand Down Expand Up @@ -238,7 +247,8 @@ public function get_csrftoken(){
$cache_file = $this->cache('csrftoken');
if($cache_file == false){
$csrftoken_html = $this->get($url, $this->headers);
preg_match('|{"config":{"csrf_token":"(.*?)"|is', $csrftoken_html['body'], $csrftoken);
$new_html = str_replace("\\","",$csrftoken_html['body']);
preg_match('|{"config":{"csrf_token":"(.*?)"|is', $new_html, $csrftoken);
$csrftoken = $csrftoken[1];
$this->cache('csrftoken', $csrftoken);
}
Expand Down Expand Up @@ -466,7 +476,7 @@ public function create_cookie($array = false, $session_id = true){

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

if($session_id === true){
Expand Down
16 changes: 9 additions & 7 deletions src/Instagram/InstagramUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,18 @@ public function get_user_id($username = null){
$url = 'https://www.instagram.com/web/search/topsearch/?query='.$username;

$json = $this->get($url);
$json = json_decode($json['body']);
if($json != null){
$json = json_decode($json['body']);

$user_id = 0;
foreach($json->users as $user){
if($username == $user->user->username){
$user_id = $user->user->pk;
$user_id = 0;
foreach($json->users as $user){
if($username == $user->user->username){
$user_id = $user->user->pk;
}
}
}

$this->cache('users/'.$username.'-id', $user_id);
$this->cache('users/'.$username.'-id', $user_id);
}
}
else{
$user_id = $cache;
Expand Down

0 comments on commit 55a72ae

Please sign in to comment.