cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Fwd: curl:cookies

From: peeyush gulati <peeyushgulati_at_gmail.com>
Date: Wed, 9 Jan 2008 10:07:24 +0530

Dear All

I am trying to code a php-script that would automatically log a user
into mediawiki. The script and mediawiki are on the same server.

eg Browser----->Script----->Mediawiki

Please refer to the code below :

<?php

require_once "HTTP/Request.php";
$req =& new HTTP_Request();
function hitForm($loginURL, $loginFields, $referer="") {
        $ch = curl_init();"
        curl_setopt($ch, CURLOPT_COOKIEJAR,"cookies.txt ");
        curl_setopt($ch, CURLOPT_COOKIEFILE,"cookies.txt ");
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); "
        curl_setopt($ch, CURLOPT_URL, $loginURL);
        curl_setopt($ch, CURLOPT_POST, 1);"
        curl_setopt($ch, CURLOPT_REFERER, $referer);"
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);"
        curl_setopt($ch, CURLOPT_POSTFIELDS, $loginFields);"
        $ret = curl_exec($ch);
        curl_close($ch);"
        return $ret;

}

$loginURL="
http://localhost/login.php?title=Special:Userlogin&action=submitlogin&type=login";
$loginFields = "wpName=peeyush&wpPassword=redhat&wpLoginattempt=Log+in";
$referer="
http://localhost/main/index.php?title=Special:Userlogin&returnto=Special:Userlogout";

echo hitForm($loginURL,$loginFields,$referer);
?>

I am able to login in using the above script but if i try to navigate
further in the application it does not helps me.

I also executed curl_setopt($ch, CURLOPT_COOKIEFILE,
"/tmp/cookieFileName"); to navigate to further pages. But it doesn't
works. Is this all some platform dependent. I am implementing this all
on linux platform.

Can some one help on this !!!!

Thanks
Peeyush

-- 
Thanks and Regards
Peeyush Gulati
+91-9916304135
-- 
Thanks and Regards
Peeyush Gulati
+91-9916304135

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-01-09