Answer the question
In order to leave comments, you need to log in
How to login to Instagram without API?
Hello!
What is the actual question.
I’m trying to log in to instagram, but for this I need to get Set-Cookie from the instance, which I can’t get through get_headers(' https://www.instagram.com ', 1) I already did it through curl, I can’t do anything, maybe just because I'm stupid, which is most likely, I ask for help, point me in the right direction, what I'm doing wrong, below I'm attaching the code of what and how I'm doing.
$load_cook = get_headers('https://www.instagram.com', 1);
$load_cook = $this->parseCookies($load_cook['Set-Cookie'], true);
$paramArr = array(
'username' => $this->userInsta,
'password' => $this->passInsta
);
$param = http_build_query($paramArr);
$opts = array(
'http'=>array(
'method' => "POST",
'header' => "Content-Type: application/x-www-form-urlencoded;\r\n" .
"cookie: csrftoken=".$load_cook['csrftoken']."; mid=".$load_cook['mid'].";\r\n" .
"referer: https://www.instagram.com/\r\n" .
"x-csrftoken: ".$load_cook['csrftoken']."\r\n" .
"user-agent: ".$this->userAgent."\r\n",
'content' => $param
)
);
$context = stream_context_create($opts);
$infa_auth = @file_get_contents('https://www.instagram.com/accounts/login/ajax/', false, $context);
$load_cook = get_headers('https://www.instagram.com', 1);
array(17) {
[0]=>
string(15) "HTTP/1.1 200 OK"
["Content-Type"]=>
string(24) "text/html; charset=utf-8"
["Vary"]=>
string(40) "Cookie, Accept-Language, Accept-Encoding"
["Content-Language"]=>
string(2) "en"
["Date"]=>
string(29) "Thu, 24 Oct 2019 22:41:15 GMT"
["Strict-Transport-Security"]=>
string(16) "max-age=31536000"
["Cache-Control"]=>
string(44) "private, no-cache, no-store, must-revalidate"
["Pragma"]=>
string(8) "no-cache"
["Expires"]=>
string(29) "Sat, 01 Jan 2000 00:00:00 GMT"
["X-Frame-Options"]=>
string(10) "SAMEORIGIN"
["X-Content-Type-Options"]=>
string(7) "nosniff"
["X-XSS-Protection"]=>
string(1) "0"
["x-aed"]=>
string(2) "11"
["Access-Control-Expose-Headers"]=>
string(18) "X-IG-Set-WWW-Claim"
["X-FB-TRIP-ID"]=>
string(10) "1679558926"
["Connection"]=>
string(5) "close"
["Content-Length"]=><code></code>
string(5) "37471"
}
fast:~ fast$ curl -I https://www.instagram.com
HTTP/2 200
content-type: text/html; charset=utf-8
vary: Cookie, Accept-Language, Accept-Encoding
content-language: en
date: Thu, 24 Oct 2019 22:42:32 GMT
content-length: 37472
strict-transport-security: max-age=31536000
cache-control: private, no-cache, no-store, must-revalidate
pragma: no-cache
expires: Sat, 01 Jan 2000 00:00:00 GMT
x-frame-options: SAMEORIGIN
content-security-policy: report-uri https://www.instagram.com/security/csp_report/; default-src 'self' https://www.instagram.com; img-src https: data: blob:; font-src https: data:; media-src 'self' blob: https://www.instagram.com https://*.cdninstagram.com https://*.fbcdn.net; manifest-src 'self' https://www.instagram.com; script-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://*.cdninstagram.com wss://www.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net 'unsafe-inline' 'unsafe-eval' blob:; style-src 'self' https://*.www.instagram.com https://www.instagram.com 'unsafe-inline'; connect-src 'self' https://instagram.com https://www.instagram.com https://*.www.instagram.com https://graph.instagram.com https://*.graph.instagram.com https://*.cdninstagram.com https://api.instagram.com wss://www.instagram.com wss://edge-chat.instagram.com https://*.facebook.com https://*.fbcdn.net https://*.facebook.net chrome-extension://boadgeojelhgndaghljhdicfkmllpafd blob:; worker-src 'self' blob: https://www.instagram.com; frame-src 'self' https://instagram.com https://www.instagram.com https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src 'none'; upgrade-insecure-requests
x-content-type-options: nosniff
x-xss-protection: 0
x-aed: 11
access-control-expose-headers: X-IG-Set-WWW-Claim
set-cookie: sessionid=""; Domain=instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=i.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=.i.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=www.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; Domain=.www.instagram.com; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: sessionid=""; expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
set-cookie: csrftoken=JRlhuOtpbGp3GcNDgFaVxcresaXvrt37; Domain=.instagram.com; expires=Thu, 22-Oct-2020 22:42:32 GMT; Max-Age=31449600; Path=/; Secure
set-cookie: rur=FRC; Domain=.instagram.com; HttpOnly; Path=/; Secure
set-cookie: mid=XbIo2AAEAAGg67AleuckVi4nWjgZ; Domain=.instagram.com; expires=Sun, 21-Oct-2029 22:42:32 GMT; Max-Age=315360000; Path=/; Secure
x-fb-trip-id: 1679558926
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question