$cookie =tempnam(__DIR__,'tmp');
$ch=curl_init();

curl_setopt($ch, CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_REFERER, "http://www.chsi.com.cn/cet/ ");//来源

curl_setopt($ch, CURLOPT_HEADER, 0);//头部head不输出  默认

curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X)AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12H143 MicroMessenger/6.3.9)');//设置浏览器

curl_setopt($ch,CURLOPT_COOKIEFILE, $cookie);//读取cookie

curl_setopt($ch, CURLOPT_POST, 1);//设置post数据

curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); //302跳转

curl_setopt($ch, CURLOPT_POSTFIELDS, $post);//进行post提交

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//设置返回字符串不输出  *必须

curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);//保存cookie

$data  =  curl_exec($ch);//返回的字符串  *
$url= curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
curl_close($ch);//关闭

设置SSL支持 https开头必须
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$mem = new Memcache;
$mem->connect("localhost", 11211);
$mem->set('key1', '这是值', 0, 60);
$val = $mem->get('key1');
echo "输出: " . $val;
$mem->close();

$mem1 = memcache_connect('localhost',11211);
$mem1->set('a','1');
echo $mem1->get('a');
memcache_close($mem1);
$cookie = tempnam(__DIR__,'tmp');
$url = "http://tp5.api.shanliwawa.top/admin/index/login";
$arr= [
    'username'=>"admin","password"=>'123456'
];

$ch1=curl_init();
curl_setopt($ch1, CURLOPT_URL,$url);
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_POST, 1);//设置post数据

curl_setopt($ch1, CURLOPT_FOLLOWLOCATION,1); //302跳转

curl_setopt($ch1, CURLOPT_POSTFIELDS,http_build_query($arr));//进行post提交
curl_setopt($ch1, CURLOPT_RETURNTRANSFER,1);//设置返回字符串不输出  *必须
curl_setopt($ch1, CURLOPT_COOKIEJAR, $cookie);
curl_exec($ch1);//返回的字符串  *
$info = curl_getinfo($ch1,CURLINFO_EFFECTIVE_URL);
curl_close($ch1);//关闭
$arrs = parse_url($url);
$url2 = "http://".$arrs['host']."/admin/index/index";

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL,$url2);
curl_setopt($ch,CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data  =  curl_exec($ch);
curl_close($ch);
unlink($cookie);
exit($data);
文档更新时间: 2020-07-23 19:35   作者:Yoby