ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ $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); ~~~ curl 上传 ~~~ function upimg($filename,$type='image'){ $token = WeAccount::token(); $curl = curl_init (); if (class_exists ( '/CURLFile' )) {//php5.5跟php5.6中的CURLOPT_SAFE_UPLOAD的默认值不同 curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, true ); $msg = array ( 'fieldname' => new \CURLFile ( realpath ( $filename ), 'image/jpeg' ) ); } else { $msg = array('media'=>'@'.$filename); if (defined ( 'CURLOPT_SAFE_UPLOAD' )) { curl_setopt ( $curl, CURLOPT_SAFE_UPLOAD, false ); } } curl_setopt ( $curl, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$token&type=$type"); curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER, FALSE ); curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST, FALSE ); if (! empty ( $msg )) { curl_setopt ( $curl, CURLOPT_POST, 1 ); @curl_setopt ( $curl, CURLOPT_POSTFIELDS, $msg ); } curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 ); $data = curl_exec ( $curl ); curl_close ( $curl ); return $data; } ~~~ ~~~ $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); ~~~