[imp] Authentication Fun
Derek Martin
derek at younet.okstate.edu
Sun Dec 22 20:30:12 PST 2002
Hi everyone. Here is an odd one - I want to perform the HORDE/IMP login
automatically from another system by using CURL. Can anyone point me in
the direction of some CURL code that could help me with this? This is
what I have so far but it (obviously) doesn't work as it is way
incomplete. REASON: Working on a single sign on system for a portal
that I am building for my university and want to log people in to
multiple systems via one login box.
My current php file:
<?php
$query =
"actionID=96&mailbox=INBOX&imapuser=MYUSERNAME&pass=MYPASSWORD&namespace
=&server=EMAILSERVER&port=143&protocol=imap&folders=&new_lang=en";
$ch = curl_init();
if (!curl_setopt($ch, CURLOPT_URL, "locationtoimp/imp/redirect.php"))
{
echo "Failed to set url.";
}
if (!curl_setopt($ch, CURLOPT_VERBOSE, 1)) {
echo "Failed to set verbose.";
}
if (!curl_setopt($ch, CURLOPT_FAILONERROR, 0)) {
echo "Failed to set verbose.";
}
/*
if (!curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;
MSIE 5.01;
Windows NT 5.0)")) {
echo "Failed to set user agent.";
}
if (!curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1)) {
echo "Failed to set follow location";
}
if (!curl_setopt($ch, CURLOPT_REFERER, "locationofreferrer")) {
echo "Failed to set referer.";
}
if (!curl_setopt($ch, CURLOPT_POST, 1)) {
echo "Failed to set post option.";
}
if (!curl_setopt($ch, CURLOPT_POSTFIELDS, "$query")) {
echo "Failed to set post fields.";
}
$result = curl_exec($ch);
if (!$result) {
echo "Curl Error: ".curl_errno($ch)."<br>";
echo "Description: ".curl_error($ch);
curl_close($ch);
exit;
} else {
echo "<pre>";
echo "Hmph: ";
echo curl_errno($ch)." -";
echo curl_error($ch) . "<br>";
print_r($result);
echo "</pre>";
// while (list($key, $val) = each($Result)) echo $key . ". " . $val
. "<br>"
;
curl_close($ch);
}
?>
More information about the imp
mailing list