CURL 补充
来源:互联网 发布:校园网络诈骗小品剧本 编辑:程序博客网 时间:2024/06/05 04:11
注意几点:1.获取认证成功后的cookie2.发送cookie字符串用curl 的参数 CURLOPT_COOKIE,而不是发送cookie文件地址的CURLOPT_COOKIEFILE<?php
header ('Content-Type: text/html; charset=utf-8');
$id='';
$psw='';
$pswd=strtoupper(md5($psw));
$url_login = "http://202.119.81.112:9080/njlgdx/xk/LoginToXk?method=verify&USERNAME=$id&PASSWORD=$pswd";
echo $url_login;
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url_login);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content=curl_exec($ch);
curl_close($ch);
preg_match('/Set-Cookie:(.*);/iU',$content,$str);
print_r($str);
$cookie=trim($str[1]);
echo $cookie;
$url="http://202.119.81.112:9080/njlgdx/kscj/cjcx_list";
$data = array (
'xsfs'=>'all',
);
//post
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect'));
//// mark!! CURLOPT_COOKIE
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
$re=curl_exec($ch);
curl_close($ch);
echo $re;
?>
- CURL 补充
- curl
- curl
- CURL
- curl
- curl
- Curl
- cURL
- CURL
- curl
- curl
- curl
- curl
- curl
- curl
- CURL
- curl
- curl
- 包装类DataOutputStream、DataInputStream的常见用法
- JAVA 异常 throwable exception error throws throw
- 学习Spring必学的Java基础知识(1)----反射
- Spring的事务管理难点剖析(2):应用分层的迷惑
- 学习Spring必学的Java基础知识(3)----PropertyEditor
- CURL 补充
- mysql及mysqli中文乱码解决办法
- 1039. 到底买不买
- SpringMVC前传(4)
- 贪心算法二分法枚举
- 1004
- HDU 1002 A + B Problem II
- 树状数组的应用(区间修改,区间查询,多维树状数组)
- 树