sub wx_init {
#$login_url ="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=-$now&lang=zh_CN&pass_ticket=$pass_ticket";
my @chatroom_id = ();
#my $response= $browser->post("https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit", [ "r" => "-$now","lang" => "zh_CN","pass_ticket"=>"$pass_ticket"]); #多加了
$login_url ="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=-$now&lang=zh_CN&pass_ticket=$pass_ticket";
my $post = {
BaseRequest => {
Uin => $wxuin,
Sid => $wxsid,
Skey => $Skey,
DeviceID => $DeviceID,
}
};
use JSON qw(encode_json);
$json_string = encode_json($post);
my $req = HTTP::Request->new(
'POST' => $login_url
# ,
# [ 'r' => "-$now", 'lang' => 'zh_CN', 'pass_ticket' => "$pass_ticket" ]
);
$req->referer("https://wx.qq.com/?&lang=zh_CN");
$req->content_type('application/json; charset=UTF-8');
#post请求,如果有发送参数,必须要有这句
$req->content("$json_string"); #发送post的参数
my $res = $ua->request($req);
print $res->content(); #获取的是响应正文
};
&wx_login();
&wx_ticket();
&wx_init();
print "1111111111111111\n";
my $cv = AnyEvent->condvar;
$cv->recv;
lwp post发送json数据:
https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=835023443&lang=zh_CN&pass_ticket=Pu6mmRTRUaapMi%252F6PvAqoGWxSv9fpWkl2z54LMelmbCu1C8axYqX8ykBiIuhi87%252B
$login_url ="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=-$now&lang=zh_CN&pass_ticket=$pass_ticket";
{"BaseRequest":{"Uin":"1284510822","Sid":"oYlYL2QfdCo/9p2W","Skey":"@crypt_597aeefd_1ae3a79a94a77a11cddbff51ff836252"
,"DeviceID":"e173991914404491"}}
my $post = {
BaseRequest => {
Uin => $wxuin,
Sid => $wxsid,
Skey => $Skey,
DeviceID => $DeviceID,
}
};