@
ooh 试过了,把浏览器中请求复制成 curl 然后改成 php,但是还是不行...另外看到除了主页面的请求外还有 xhr 和 ws,完全进入知识盲区...
```
public function getUserLogin()
{
$userInfo = $this->checkZkeysStatus();
$plesk_user = md5($userInfo['id'].$this->md5key);
$params = "{ \"params\": [ \"--get-login-link\", \"-user\", \"".$plesk_user."\" ]}";
$result = $this->_getRest('cli/admin/call',$params);
return $result['stdout'];
}
protected function getUserCookies()
{
$login_url = $this->getUserLogin();
$ch = curl_init();
$plesk_cookie_jar = '/tmp/cfpro_cookie_'.$plesk_user.'.txt';
header("Content-Type:text/html;charset=utf-8");
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $plesk_cookie_jar);
curl_setopt($ch, CURLOPT_COOKIEFILE, $plesk_cookie_jar);
$result = curl_exec($ch);
curl_close($ch);
return $plesk_cookie_jar;
}
//就是这一步出问题了
public function bindCF($cfemail,$cfpass)
{
$userInfo = $this->checkZkeysStatus();
$zoneInfo = M('cloudflare')->find(['user_id' => $userInfo['id']]);
$activate_url = '/modules/servershield/index.php/index/';
$post = array('simple'=>1,'cfemail'=>$cfemail, 'cfpass'=>$cfpass);
$plesk_cookie_jar = $this->getUserCookies();
header("Content-Type: application/x-www-form-urlencoded");
curl_setopt($ch, CURLOPT_URL, $activate_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_COOKIEFILE, $plesk_cookie_jar);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, true);
}
```