curl重定向登录凭据保护

时间:2016-04-18 08:21:52

标签: curl password-protection

我正在考虑在网站上使用curl登录我拥有的不同网站,所以我在网上找到了一些示例代码。现在我的问题是:以这种方式提供用户名和密码是否省事。否则,我该怎么做呢?

$url_post = "http://localhost/joomla/joomlathree/index.php?option=com_users&task=user.login&lang=en";
$postdata = "username=".urlencode($uname)."&password=".urlencode($upswd)."&return=".urlencode($matches1[1][0])."&".urlencode($matches2[1][0])."=1";
curl_setopt($ch, CURLOPT_URL, $url_post);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$results1 = curl_exec($ch);

$url_data = "http://localhost/joomla/joomlathree/index.php?option=com_users&lang=en"; //MOD REWRITE Disabled
curl_setopt($ch, CURLOPT_URL, $url_data);

$results2 = curl_exec($ch);
$error = curl_error($ch);
$errno = curl_errno($ch);
echo ($error);

curl_close($ch);

1 个答案:

答案 0 :(得分:0)

卷曲操作使用安全。但是,您应该使用https来发送凭据,因为没有其他人可以轻松地从请求中读取它们。