1

I'm replacing old legacy system (Joomla) with Laravel.

At the beginning we have some pages in old and some in new framework so I planned to allow user to login with Laravel authentication method and then forward the credentials to Joomla, so user would be logged in to both at once.

Currently I'm stuck with forwarding part, as I can't figure out how to send login POST variables to Joomla URL.

[code]

    $url         = 'www.test.dev/index.php/lv/login?task=user.login';
    $fields      = [
        'username' => $credentials['username'],
        'password' => $credentials['password']
    ];
    $ch          = curl_init();
    curl_setopt($ch, CURLOPT_POSTFIELDS,
        http_build_query($fields));

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, count($fields));

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);

[/code]

Riho
  • 4,523
  • 3
  • 33
  • 48
  • You can do this with file_get_contents, see: http://stackoverflow.com/questions/2445276/how-to-post-data-in-php-using-file-get-contents – Progrock Feb 19 '16 at 10:40

1 Answers1

0

Use curl or Guzzle to send your post request to the joomla app.

oseintow
  • 7,221
  • 3
  • 26
  • 31