php用账号密码模拟登陆解决办法

WBOY
Release: 2016-06-13 12:08:02
Original
984 people have browsed it

php用账号密码模拟登陆

http://112.78.104.13
Copy after login


账号:zm1000,密码a123456,我想用php模拟登陆,但是总是不行,是不是提交方式不对?求大神解答!

或者提取出cookie来也行,但是好像又不支持cookie
------解决思路----------------------
1、http://112.78.104.13 是框架页。含有公共变量和函数
2、含登录框的框架是 http://112.78.104.13/app/member
3、表单目标页是 http://112.78.104.13/app/member/login.php
4、登录后返回
<script><br />top.uid = '360eae3m12904263l134939190';<br />top.langx = 'zh-tw';<br />top.liveid = 'cbcfc6cdcec29bcdccc9cd'<br />top.casino = 'SI2';<br />top.hot_game = '';<br />top.hasLogin = 'login';<br /></script><br /><script>window.location.href = 'http://112.78.104.13/app/member/FT_index.php?mtype=3&uid=360eae3m12904263l134939190&langx=zh-tw';</script><br />
Copy after login
仅 php 只能做到这里,虽然可析出跳转的目标页,但数据是由 js 产生的。只能得到页面框架

参考代码
$url = 'http://112.78.104.13/app/member';<br />$url1 = 'http://112.78.104.13/app/member/login.php';<br />$d = array('username' => 'zm1000', 'passwd' => 'a123456');<br /><br />//echo file_get_contents($url);<br />//print_r(get_headers($url));<br /><br />echo postdata($url1, $d);<br /><br />function postdata($url, $data){<br />    $opts = array(<br />        'http' => array(<br />            'method' => 'POST',<br />            'header' => 'content-type:application/x-www-form-urlencoded',<br />            'user_agent' => $_SERVER['HTTP_USER_AGENT'],<br />            'content' => http_build_query($data)<br />        )    <br />    );<br />    $context = stream_context_create($opts);<br />    $result = file_get_contents($url, false, $context);<br />    return $result;<br />}
Copy after login


只为展示使用 file_get _contents 模拟提交

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template