• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

php 模拟微信账号登录

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
  1. // 微信公众账号
  2.  define("Account", "100000000");
  3. // 微信公众号登陆密码  MD5加密
  4.  define("PassWord", "8743E01B6FAA881EDFCA08ADAE979BC1");
  5.  
  6. class __user_remote_opera{
  7. // 模拟登录
  8. public function login(){
  9. $snoopy = new Snoopy(); 
  10. $submit = "http://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
  11. $post["username"] = Account;
  12. $post["pwd"] = PassWord;
  13. $post["f"] = "json";
  14. $snoopy->submit($submit,$post);
  15. $cookie = \'\';
  16. foreach ($snoopy->headers as $key => $value) {
  17. $value = trim($value);
  18. if(strpos($value,\'Set-Cookie: \') || strpos($value,\'Set-Cookie: \') === 0){
  19. $tmp = str_replace("Set-Cookie: ","",$value);
  20. $tmp = str_replace("Path=/","",$tmp);
  21. $cookie .= $tmp;
  22. }
  23. }
  24. if(!$cookie){
  25. $this->login();
  26. }else{
  27. $this->write("cookie.log",$cookie);
  28. return $cookie;
  29. }
  30. }
  31. // 主动推送信息
  32. public function sendTextMsg($fakeId,$content){
  33. $cookie = $this->read(\'cookie.log\');
  34. $send_snoopy = new Snoopy(); 
  35. $send_snoopy->agent = "(Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0)"; //伪装浏览器  
  36. $send_snoopy->referer = "http://mp.weixin.qq.com/cgi-bin/singlemsgpage?fromfakeid=".$fakeId."&msgid=&source=&count=20&t=wxm-singlechat&lang=zh_CN"; //伪装来源页地址 http_referer  
  37. $send_snoopy->rawheaders[\'Cookie\'] = $cookie;
  38. $send_snoopy->rawheaders["Pragma"] = "no-cache"; //cache 的http头信息  
  39. $send_snoopy->rawheaders["Host"] = "mp.weixin.qq.com"; 
  40. $post = array();
  41. $post[\'tofakeid\'] = $fakeId;
  42. $post[\'type\'] = 1;
  43. $post[\'content\'] = $content;
  44. $post[\'ajax\'] = 1;
  45. $submit = "http://mp.weixin.qq.com/cgi-bin/singlesend?t=ajax-response";
  46. $send_snoopy->submit($submit,$post);
  47. $result = $send_snoopy->results;
  48. if($result[\'ret\'] != 0){
  49. $cookie = $this->login();
  50. $this->sendTextMsg($fakeId,$content);
  51. }else{
  52. return $result;
  53. }
  54. }
  55. public function write($filename,$content){
  56. $__sae = new SaeStorage();
  57. $fp = $__sae->write("tempfile",$filename,$content);
  58. }
  59. // 读文件
  60. public function read($filename){
  61. $__sae = new SaeStorage();
  62. if($__sae->fileExists("tempfile",$filename)){
  63. $data = \'\';
  64. $data = $__sae->read("tempfile",$filename);
  65. if($data){
  66. $send_snoopy = new Snoopy(); 
  67. $send_snoopy->rawheaders[\'Cookie\'] = $data;
  68. $submit = "http://mp.weixin.qq.com/cgi-bin/getcontactinfo?t=ajax-getcontactinfo&lang=zh_CN&fakeid=";
  69. $send_snoopy->submit($submit,array());
  70. $result = json_decode($send_snoopy->results,1);
  71. if(!$result){
  72. return $this->login();
  73. }else{
  74. return $data;
  75. }
  76. }else{
  77. return $this->login();
  78. }
  79. }else{
  80. return $this->login();
  81. }
  82. }
  83.  
  84. }

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP中单引号、双引号和转义字符发布时间:2022-07-10
下一篇:
phppreg_replace去除htmlxml注释发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap