gpt4 book ai didi

php - SSL 问题,登录网站

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

我有这段代码可以为我正在使用的机器人登录名为 Pinger TextFree 的服务器:

<?php
function sendRequest($url, $postorget, $fields = array(), $proxy)
{
$cookie_file = "cookies.txt";

//Initiate connection
$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, $header); // set url
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url); // set url
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return the transfer
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // allow https
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'); // random agent
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // automatically follow Location: headers (ie redirects)
curl_setopt($ch, CURLOPT_AUTOREFERER, 1); // auto set the referer in the event of a redirect
curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // ibm likes to redirect a lot, make sure we dont get stuck in a loop
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); // file to save cookies in
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); // file to read cookies from
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 40); //timeout time for curl
curl_setopt($ch, CURLOPT_PORT, 80); //port to connect to (default 80 obviously)

//Check to see if a proxy is being used
if(isset($proxy)){
//Tell cURL you're using a proxy
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
//Set the proxy
curl_setopt($ch, CURLOPT_PROXY, $proxy);
}

//Check if request is POST or GET
if ($postorget == "post" OR $postorget == "POST")
{
curl_setopt($ch, CURLOPT_POST, true); // use POST
if (is_array($fields)){
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields)); // key => name gets turned into &key=name
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // &key=name passed in
}
} else {
curl_setopt($ch, CURLOPT_POST, false); // use GET
}

$content = curl_exec($ch); // return html content
$info = curl_getinfo($ch); // return transfer info
$error = curl_error($ch); // return any errors

curl_close($ch);

$request = array('content' => $content,
'error' => $error,
'info' => $info);

return $request;
}

//Login details
$username = "usernamehere";
$password = "passwordhere";

//GET the initial login page
$initFields = "";
$initOutput = sendRequest("http://www.pinger.com/tfw/?t=1360619019053", "GET", $initFields);

echo "<textarea cols='100' rows='400'>";
print_r($initOutput);
echo "</textarea>";

//Login to pinger
$loginFields = "{\"username\":\"".$username."\",\"password\":\"".$password."\",\"clientId\":\"textfree-in-flash-web-free-1360619009-8CA1C5C1-38ED-2E31-3248-CB367450A20F\"}";
$loginOutput = sendRequest("https://api.pinger.com/1.0/web/login", "POST", $loginFields);

echo "<textarea cols='100' rows='400'>";
print_r($loginOutput);
echo "</textarea>";

?>

出于某种原因,每次我尝试运行此脚本时,我得到的都是“连接到 api.pinger.com:80 时出现未知的 SSL 协议(protocol)错误”

我在这里做错了什么?我什至会在 setop 中指定 SSL2,但它永远挂起 - 我无法让它工作!

这是我要自动化的应用程序:http://www.pinger.com/tfw/

它在 flash 中,但我正在使用 Fiddler 嗅探 HTTP/HTTPS 请求以使用 cURL 自动执行它们。

你们有什么想法吗?

最佳答案

错误很明显在行中

curl_setopt($ch, CURLOPT_PORT, 80); //port to connect to (default 80 obviously)

HTTPS 服务器默认监听端口 443。简单地删除这一行就足够了;然后,curl 将从 URL 中的协议(protocol)中找出端口。

关于php - SSL 问题,登录网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14843393/

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