Home > Joomla 1.5 > Login in Joomla 1.5 through curl

Login in Joomla 1.5 through curl

First of all we need three inputs.
$uname = “test”;
$upswd = “123456”;
$url = ‘http://localhost/joomla/index.php?option=com_user&view=login’

//Initialize curl. This is one time curl session no need another session.
$ch = curl_init();

//Try to loging in[Joomla]
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_COOKIEJAR, ‘./cookie.txt’);
curl_setopt($ch, CURLOPT_COOKIEFILE, ‘./cookie.txt’);
curl_setopt($ch, CURLOPT_HEADER, FALSE );
$ret = curl_exec($ch);//access login page
if (!preg_match(‘/name=”([a-zA-z0-9]{32})”/’, $ret, $spoof)) {
preg_match(“/name='([a-zA-z0-9]{32})’/”, $ret, $spoof);
// Collecting all POST fields
$postfields = array();
$postfields[‘username’] = $uname;
$postfields[‘passwd’] = $upswd;
$postfields[‘lang’] = ”;
$postfields[‘option’] = ‘com_user’;
$postfields[‘task’] = ‘login’;
$postfields[$spoof[1]] = ‘1’;
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$ret = curl_exec($ch);//Get result after login page.
//Close curl and free server recourses.

Categories: Joomla 1.5
  1. December 12, 2011 at 12:40 am

    Thanks for that awesome posting. It saved MUCH time 🙂

  2. Tim
    August 3, 2012 at 9:02 pm

    Would using something like this allow an RSS reader to load Joomla 2.5 RSS feeds that are not “Public”? The reader would need to use something like: http://user:pass@joomlawebsitedomain/rssfeed

    Joomla doesn’t seem to natively support protected RSS feeds. Any thoughts?

  3. April 8, 2013 at 5:20 am

    That is a great tip particularly to those fresh to the blogosphere.
    Brief but very accurate information… Appreciate your sharing this one.
    A must read post!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: