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

@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