php curl cloudflare,求助 关于 PHP 中 curl 模拟浏览器提交 POST 请求 [帮忙解答送 CloudFlarePro 订阅]...

CloudRaft

110 天前

@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);

}

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值