Skip to content

Instantly share code, notes, and snippets.

@witchfindertr
Created September 11, 2022 17:04
Show Gist options
  • Select an option

  • Save witchfindertr/d662ee148e82feb31e708f5aa61daedd to your computer and use it in GitHub Desktop.

Select an option

Save witchfindertr/d662ee148e82feb31e708f5aa61daedd to your computer and use it in GitHub Desktop.
def get_user_id(username):
headers = {
'authority': 'i.instagram.com',
'accept': '*/*',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
'origin': 'https://www.instagram.com',
'referer': 'https://www.instagram.com/',
'sec-ch-ua': '"Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
'x-csrftoken': '2SAvFYoHgS8GwleiP7j5vTLPqRJX4IFL',
'x-ig-app-id': '936619743392459',
}
params = {
'username': username,
}
r = requests.get('https://i.instagram.com/api/v1/users/web_profile_info/', params=params, headers=headers)
id = r.text.split('"id":"')[2].split('"')[0]
return
https://github.com/Hazza3100/Instagram-Aio/blob/main/main.py
@witchfindertr
Copy link
Author

function getUserId($username){
$response = instagramRequest("https://i.instagram.com/api/v1/users/web_profile_info/?username={$username}");
$response_obj = json_decode($response);
$user_id = $response_obj -> data -> user -> id;

return $user_id;
}

//Returns if the user account is private or not
function isPrivate($username){
$response = instagramRequest("https://i.instagram.com/api/v1/users/web_profile_info/?username={$username}");
$response_obj = json_decode($response);
$is_private = $response_obj -> data -> user -> is_private;

return $is_private;

}

//Returns an array of Instagram stories for the provided user id
function getStories($user_id){
$response = instagramRequest("https://i.instagram.com/api/v1/feed/user/{$user_id}/reel_media/");
$response_obj = json_decode($response);

@witchfindertr
Copy link
Author

   "https://i.instagram.com/api/v1/users/web_profile_info/?username=" +
      username,
    {
      headers: {
        "x-ig-app-id": "936619743392459",
      },

@witchfindertr
Copy link
Author

@witchfindertr
Copy link
Author

@witchfindertr
Copy link
Author

from requests import get
sessions = open('sessions.txt','r').read().splitlines()
def check(session):
url = 'https://i.instagram.com/api/v1/users/search/?timezone_offset=10800&q=zyl7&count=10&rank_token=0'
headers={
"User-Agent": "Instagram 9.7.0 Android (24/7.0; 420dpi; 1080x1920; samsung; SM-N920P; nobleltespr; samsungexynos7420; ar_IQ)",
"Cookie": f"sessionid={session}"
}
resp = get(url,headers=headers).text
return resp
work = 0
notwork = 0
for session in sessions:
resp = check(session)
if '"status":"ok"' in resp:
print(session)
work +=1
with open('sessions working.txt', 'a', encoding='utf-8', errors='ignore') as p:
p.writelines(session + '\n')
else:
notwork+=1
print(f'Working : {str(work)}')

@witchfindertr
Copy link
Author

@witchfindertr
Copy link
Author

$search = curl_init();
curl_setopt($search, CURLOPT_URL, "https://www.instagram.com/web/search/topsearch/?query=$word1");
curl_setopt($search, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($search, CURLOPT_ENCODING , "");
curl_setopt($search, CURLOPT_HTTPHEADER, [
'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9',
'accept-language: en-US,en;q=0.9',
'cache-control: max-age=0',
'cookie: '.$accounts[$file]['cookies'],
'user-agent: '.$accounts[$file]['useragent']
]);
$search = curl_exec($search);
$search = json_decode($search);

@witchfindertr
Copy link
Author

public function get_stories($username = null){
$username = $this->functions->user->get_user_id($username ?? $this->username);
$url = 'https://i.instagram.com/api/v1/feed/user/'.$username.'/story/?supported_capabilities_new=%5B%7B%22name%22%3A%22SUPPORTED_SDK_VERSIONS%22%2C%22value%22%3A%22114.0%2C115.0%2C116.0%2C117.0%2C118.0%2C119.0%2C120.0%2C121.0%2C122.0%2C123.0%2C124.0%2C125.0%2C126.0%2C127.0%2C128.0%2C129.0%2C130.0%22%7D%2C%7B%22name%22%3A%22FACE_TRACKER_VERSION%22%2C%22value%22%3A%2214%22%7D%2C%7B%22name%22%3A%22segmentation%22%2C%22value%22%3A%22segmentation_enabled%22%7D%2C%7B%22name%22%3A%22COMPRESSION%22%2C%22value%22%3A%22ETC2_COMPRESSION%22%7D%2C%7B%22name%22%3A%22world_tracker%22%2C%22value%22%3A%22world_tracker_enabled%22%7D%2C%7B%22name%22%3A%22gyroscope%22%2C%22value%22%3A%22gyroscope_enabled%22%7D%5D';
$json = $this->get($url);
$json = json_decode($json['body']);

        return $json;
    }

    public function get_my_story_seen_list($media_id = null){

        if($media_id != null){
            $url  = 'https://i.instagram.com/api/v1/media/'.$media_id.'/list_reel_media_viewer/?supported_capabilities_new=[{"name":"SUPPORTED_SDK_VERSIONS","value":"114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0"},{"name":"FACE_TRACKER_VERSION","value":"14"},{"name":"segmentation","value":"segmentation_enabled"},{"name":"COMPRESSION","value":"ETC2_COMPRESSION"},{"name":"world_tracker","value":"world_tracker_enabled"},{"name":"gyroscope","value":"gyroscope_enabled"}]';
            $json = $this->get($url);
            $json = json_decode($json['body']);
            return $json;
        }

        return false;
    }

@witchfindertr
Copy link
Author

// avoid 429 Rate limit from Instagram
sleep(1);

@witchfindertr
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment