-
-
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 |
public function get_user_id($username = null){
$username = $username ?? $this->username;
if($username != null){
$cache = $this->cache($username.'-id');
if($cache === false){
$url = 'https://www.instagram.com/web/search/topsearch/?query='.$username;
$json = $this->request($url);
$json = json_decode($json['body']);
$user_id = 0;
foreach($json->users as $user){
if($username == $user->user->username){
$user_id = $user->user->pk;
}
}
$this->cache($username.'-id', $user_id);
}else{
$user_id = $cache;
}
return $user_id;
}
return false;
}
function searchUser(query) {
return new Promise((resolve, reject) => {
Axios.get('https://www.instagram.com/web/search/topsearch/?query=' + query , {
headers: {
Cookie: sessionid=${sesid}
}
}).then(({ data }) => {
const all = data.users
const result = []
for (let i = 0; i < all.length; i++) {
result.push({
number: all[i].position + 1,
pk_id: all[i].user.pk,
username: all[i].user.username,
name: all[i].user.full_name,
latest_reel: all[i].user.latest_reel_media,
is_private: all[i].user.is_private,
is_verified: all[i].user.is_verified,
pic: all[i].user.profile_pic_url
})
}
resolve(result)
}).catch(reject)
})
}
const GENERAL_SEARCH = 'https://www.instagram.com/web/search/topsearch/?query={query}&count={count}';
def search_for_user(user, username)
rank_token = IgApi::Http.generate_rank_token user.session.scan(/ds_user_id=([\d]+);/)[0][0]
endpoint = 'https://i.instagram.com/api/v1/users/search/'
param = format('?is_typehead=true&q=%s&rank_token=%s', username, rank_token)
result = api.get(endpoint + param)
.with(session: user.session, ua: user.useragent).exec
result = JSON.parse result.body, object_class: OpenStruct
if result.num_results > 0
user_result = result.users[0]
user_object = IgApi::User.new username: username
user_object.data = user_result
user_object.session = user.session
user_object
end
const getStories = module.exports.getStories = (userId) => {
return new Bluebird((resolve, reject) => {
agent
.get(util.format('https://i.instagram.com/api/v1/feed/user/%s/story/', userId))
.set('User-Agent','Instagram 10.26.0 (iPhone7,2; iOS 10_1_1; en_US; en-US; scale=2.00; gamut=normal; 750x1334) AppleWebKit/420+')
.set('Accept', '/')
.set('Referer', 'https://www.instagram.com/')
.set('Accept-Encoding', 'gzip, deflate, br')
.set('Accept-Language', 'en-US,en;q=0.8')
.set('Cookie', util.format(
'sessionid=%s; ds_user_id=%s; csrftoken=%s',
webCookies.sessionid, webCookies.ds_user_id, webCookies.csrftoken
))
.withCredentials()
.end(function(err, res){
if (err || !res.ok) {
return reject(err);
} else {
if(_.isUndefined(res.body.reel) || .isNull(res.body.reel)){
return resolve([]);
}
return resolve(.map(res.body.reel.items, (item) => {
return {
type: item.media_type == 1 ? 'image' : 'video',
originalContentUrl: item.media_type == 1 ?
_.head(item.image_versions2.candidates).url :
_.head(item.video_versions).url,
previewImageUrl: _.last(item.image_versions2.candidates).url
};
}));
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);
"https://i.instagram.com/api/v1/users/web_profile_info/?username=" +
username,
{
headers: {
"x-ig-app-id": "936619743392459",
},
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)}')
$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);
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;
}
// avoid 429 Rate limit from Instagram
sleep(1);
$url = 'https://i.instagram.com/api/v1/feed/user/'.$username.'/story/';
$json = $this->request($url, 'GET');
$json = json_decode($json['body']);