如何使用Delphi

时间:2016-10-07 09:43:35

标签: android http delphi ssl delphi-10.1-berlin

我已将我的Android设备与Charles代理调试器链接以分析Instagram应用程序连接,我正在尝试模拟登录过程。我得到400错误请求错误!有什么东西拧干或遗失?感谢

URL https://i.instagram.com/api/v1/accounts/login/

接头

:method POST
:authority  i.instagram.com
:scheme https
:path   /api/v1/accounts/login/
content-length  375
x-ig-connection-type    WIFI
x-ig-capabilities   3Ro=
accept-language en-GB
cookie  mid=V_aKeQABAAHIZzx8Kyla4SRkfLWo
content-type    application/x-www-form-urlencoded; charset=UTF-8
user-agent  Instagram 9.5.0 Android (19/4.4.4; 480dpi; 1080x1780; HTC/htc; HTC One_M8; htc_m8; qcom; en_GB)

表格

signed_body c30515c9084694b1976dfaf6225a5c316603b91531dfaa3f252cb7b55118cfxx.{"phone_id":"152e5b5a-12c7-4fb0-b2fe-5fe7e0bd13xx","username":"myusername","guid":"42128e20-2663-489e-8ecd-56ed190276xx","device_id":"android-eb4a35ee7ccbf3xx","password":"mypassword","login_attempt_count":"0"}
ig_sig_key_version  4

我的德尔福代码:

procedure TForm1.Button3Click(Sender: TObject);
var
  lHTTP   : TIdHTTP;
  IdSSL   : TIdSSLIOHandlerSocketOpenSSL;
  Params  : TStrings;
  X       : string;
begin
  X := Randomstring(64)+'.{"phone_id":"'+(Randomstring(8)+'-'+(Randomstring(4)+'-'+(Randomstring(4)+'-'+(Randomstring(4)+'-'+(Randomstring(12)+'","username":"myusername","guid":"'+
(Randomstring(8)+'-'+(Randomstring(4)+'-'+(Randomstring(4)+'-'+(Randomstring(4)+'-'+(Randomstring(12) +'","device_id":"android-'+(Randomstring(16)+
'","password":"mypassword","login_attempt_count":"0"}')))))))))));

 Params := TStringList.Create;
 Params.Add('signed_body=' + X);
 Params.Add('ig_sig_key_version=' + '4');
 lHTTP := TIdHTTP.Create(nil);
 try
  IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
  IdSSL.SSLOptions.Method := sslvTLSv1;
  IdSSL.SSLOptions.Mode := sslmClient;
  lHTTP.IOHandler := IdSSL;
  lHTTP.ReadTimeout := 30000;
  lHTTP.HandleRedirects := True;
  lHTTP.Request.CustomHeaders.Values[':methode'] := 'POST';
  lHTTP.Request.CustomHeaders.Values[':scheme'] := 'https';
  lHTTP.Request.CustomHeaders.Values[':accept-languages'] := 'en-GB';
  lHTTP.Request.CustomHeaders.Values[':authority'] := 'www.i.instagram.com';
  lHTTP.Request.CustomHeaders.Values[':path'] := '/api/v1/accounts/login/';
  lHTTP.Request.CustomHeaders.Values['x-ig-connection-type'] := 'WIFI';
  lHTTP.Request.CustomHeaders.Values['x-ig-capabilities'] :=  '3Ro=';
  lHTTP.Request.ContentType := 'application/x-www-form-urlencoded; charset=UTF-8';
  lHTTP.Request.UserAgent := 'Instagram 9.5.0 Android (19/4.4.4; 480dpi; 1080x1780; HTC/htc; HTC One_M8; htc_m8; qcom; en_GB)';
  lHTTP.Request.CustomHeaders.Values['accept-encoding'] := 'gzip, deflate';
  memo1.lines.Add(lhttp.Post('https://i.instagram.com/api/v1/accounts/login/', Params));

  Finally
  end;
end;

更新

我卸载了Instagrm和Facebook,再次安装,在登录界面打开它,我在Charles调试器中获取了这些数据..

URL https://i.instagram.com/api/v1/fb/show_continue_as/
:method POST
:authority  i.instagram.com
:scheme https
:path   /api/v1/fb/show_continue_as/
content-length  194
x-ig-connection-type    WIFI
x-ig-capabilities   3Ro=
accept-language en-GB
content-type    application/x-www-form-urlencoded; charset=UTF-8
user-agent  Instagram 9.5.0 Android (19/4.4.4; 480dpi; 1080x1780; HTC/htc; HTC One_M8; htc_m8; qcom; en_GB)
accept-encoding gzip, deflate  
...
Form Data
singned_body : 9278769ad8cf26b7fddb35de9cf0f1e77582a72e9b383af6c98c85d7303f62xx.{"phone_id":"152e5b5a-12c7-4fb0-b2fe-5fe7e0bd13xx","screen":"landing"}
ig_sig_key_version : 4

在Charles的set cookies列中我可以看到访问令牌,怎么样?连接序列中Get之前没有Post

我再次得到400错误! 什么是遗失或错误的?

0 个答案:

没有答案