gpt4 book ai didi

php - 使用 curl 登录 https 站点不起作用,怀疑与它有关的 godaddy 验证

转载 作者:太空宇宙 更新时间:2023-11-03 12:58:12 25 4
gpt4 key购买 nike

我使用以下通用代码登录其他 https 站点并使用表单提取记录,但它似乎不适用于 www.voip.ms。我已经创建了一个测试帐户,所以如果有人想尝试一下并告诉我我做错了什么。 (警告,该网站只提供您的 IP 地址 4 次尝试,直到它被禁止)

<?php
ini_set('max_execution_time', 300);
$username="meahmatt@aol.com";
$password="testaccount";
$url="https://www.voip.ms/m/login.php";
$cookie="cookie.txt";

$postdata = "col_email".$username."&col_password=".$password."&action=login&form1=";

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url);

curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);
echo $result;
?>

我也试过设置 CURLOPT_SSL_VERIFYPEER, TRUE 没有改变

最佳答案

我最近在尝试使用来自 godaddy 的 curl_exec 来使用 twitter api 时遇到了同样的问题。

魔术是在选项中禁用对等验证和主机验证:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // required as godaddy fails
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // required as godaddy fails

错误是证书验证问题。我在非 godaddy 服务器上使用这个确切的脚本没有问题。

CURLE_SSL_CACERT (60)
Peer certificate cannot be authenticated with known CA certificates.

完整的请求如下所示:

  $url = "https://api.twitter.com/1.1/statuses/user_timeline.json?..."
$headers = array(
"Authorization: Bearer ".$bearer."",
);

$ch = curl_init(); // setup a curl
curl_setopt($ch, CURLOPT_URL, $url); // set url to send to
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // set custom headers
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return data reather than echo
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // required as godaddy fails
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // required as godaddy fails

// $info = curl_getinfo($ch); // debug info
// var_dump($info); // dump curl info

$result = curl_exec($ch); // run the curl

curl_close($ch); // stop curling

// Check for errors and display the error message
if($errno = curl_errno($ch)) { echo "curlerror::$errno::"; }

另请注意,curl_getinfocurl_errno 在发现问题方面非常重要。

tl;dr, friend 们不要让 friend 们使用 godaddy。

关于php - 使用 curl 登录 https 站点不起作用,怀疑与它有关的 godaddy 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18789611/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com