后端开发|php教程
nbsp,curl,METHOD,headers,REQUEST
后端开发-php教程
[分享]模拟新浪微博自动登陆
博客原文地址: /lgg201/article/details/8050606
网盘搜索程序源码,vscode开监视,怎样看ubuntu的版本,tomcat ssl 宝塔,sqlite查询时排序,ecshop大转盘抽奖插件,前端框架如何弹出页面,蝈蝈是爬虫吗,后台管理系统 php,合肥网优化seo公司,开源之家网站行吗,在线制作wap表白网页,360网址导航模板下载,cmd php运行页面,药品销售管理系统课程设计,收录导航程序lzw
<?php
/**
* 功能: 模拟新浪微博登陆
* 用途: 模拟用户登陆, 以便进行后续操作, 比如自动化的控制自己的新浪app刷新某些数据
* 注意事项:
* 1. 需要安装nodejs
* 2. 需要下载新浪的加密js文件, 请到新浪登陆页查看网络请求自己下载最新版本(我当时用的: http://js./t35/miniblog/static/js/sso.js?version=e482ef2bbdaa8bc2)
* 3. 对新浪加密js文件进行修改, 以便让nodejs可以运行它
*1) 在文件前面增加下面内容
varwindow= {
location: {
hash: \,
host: \,
hostname: \,
href: /,
pathname: /,
port: \,
protocol: http:,
search: \
},
navigator: {
appCodeName: Mozilla,
appName: Netscape,
appVersion: 5.0 (Macintosh),
buildID: 713134347,
cookieEnabled: true,
doNotTrack: unspecified,
language: en-US
}
};
varlocation= window.location;
varnavigator= window.navigator;
*2) 在文件后面增加下面内容
varargv= process.argv.splice(2);
c 生成源码,ubuntu系统深度解析,tomcat解压版闪退,python 爬虫 岗位,php预览pdf文件,綦江区一站式seo推广哪家好lzw
varpubkey= argv[0],
servertime= argv[1],
nonce= argv[2],
password= argv[3];
素材网 源码,vscode 窗口程序,ubuntu客户,tomcat不要重启,sqlite查询语句实例,discuz图片滚动插件,web前端框架学习哪个好,爬虫王者荣耀英雄名称,php 最小值,石林seo优化价格,网站导航源码易语言,佳缘 网页版,房产门户模板lzw
var RSAKey = new sinaSSOEncoder.RSAKey();
RSAKey.setPublic(pubkey, 10001);
password = RSAKey.encrypt([servertime, nonce].join("\t") + "\n" + password);
console.log(password);
process.exit();
*4. 修改encode_password函数中的nodejs程序路径和修改后的新浪js文件路径
* 5. 修改用户名密码
* author: selfimpr
* blog: /lgg201
* mail: lgg860911@
*/
define(REQUEST_METHOD_GET,GET);
define(REQUEST_METHOD_POST,POST);
define(REQUEST_METHOD_HEAD,HEAD);
define(COOKIE_FILE,/tmp/sina.login.cookie);
function curl_switch_method($curl, $method) {
switch ( $method) {
case REQUEST_METHOD_POST:
curl_setopt($curl, CURLOPT_POST, TRUE);
break;
case REQUEST_METHOD_HEAD:
curl_setopt($curl, CURLOPT_NOBODY, TRUE);
break;
case REQUEST_METHOD_GET:
default:
curl_setopt($curl, CURLOPT_HTTPGET, TRUE);
break;
}
}
function curl_set_headers($curl, $headers) {
if ( empty($headers) ) return ;
if ( is_string($headers) )
$headers= explode("\r\n", $headers);
#类型修复
foreach ( $headers as &$header )
if ( is_array($header) )
$header= sprintf(\%s: %s, $header[0], $header[1]);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
}
function curl_set_datas($curl, $datas) {
if ( empty($datas) ) return ;
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
}
function curl_request($url, $method = REQUEST_METHOD_GET, $datas = NULL, $headers = NULL) {
static$curl;
if ( !$curl )
$curl= curl_init();
curl_switch_method($curl, $method);
curl_setopt($curl, CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION,TRUE);