Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

Login integration for 2 different 3rd party scripts in PHP

Hi, I am trying to create a bridge between two different scripts. One is textpattern for news/blog and another one is a social networking script (SNS). When a user creates an account in textpattern or SNS, I know that it should automatically create a clone account to the other script. But I would like to if a user logs into textpattern, how can I let it login to SNS too? Is there some kind of HTML header command that will do that automatically?

I don't want to create a whole new user session tracking routine for both, because I think that is going to be a huge work from scratch. Thank you.
0
santocki
Asked:
santocki
  • 2
  • 2
1 Solution
 
Mahdii7Commented:
It should be possible to do..

First of all, this was very confusing to me, I am assuming that you have 2 applications:
Social Networking Script
Textpattern CMS

You have both of these scripts combined in one website. You would like to allow a user to log into the website once, however each script requires a separate login by default.

Do each of these scripts require separate registration as well? I would assume so, and if you do not plan to connect the registration process I advise against merging the sign in process as there could easily be complications (different credentials).

If you just wanted to sign in to both accounts at once by a single page, examine the login protocol for each script. Do they require $_REQUEST data? Do they use this data in a function call? Since we are missing the 2 login pages, I will post 2 example login pages and let you fill in the blanks.

If this is the case, simply require() the needed scripts and call the 2 functions on a single page. Hopefully there are no conflicts and it's that simple.
<?php
// SNS Login.php
 
require_once("sns/library/login_functions.php");
 
$username = $_POST['username'];
$password = $_POST['password'];
 
if (doLogin($username, $password)){
  goToHomePage();
}
 
?>
 
<?php
// textpattern Login.php
 
require_once("textpattern/library/functions.php");
 
$uname = $_GET['txtUsername'];
$pword = $_GET['txtPassword'];
 
if (login_user($uname, $pword)){
  header("Location: http://www.somesite.com/members.php");
}
 
?>
 
<?php
// Merged login.php
 
require_once("sns/library/login_functions.php");
require_once("textpattern/library/functions.php");
 
$usrname = $_REQUEST['your_username_field'];
$passwd  = $_REQUEST['your_password_field'];
 
if (login_user($usrname, $passwd) && doLogin($usrname, $passwd)){ 
     header("Location: http://www.yoursite.com/your_landing_page.php");
}else{
   echo "login failed!";
}
 
?>
 
/*
Obviously, this is dependent on the third party applications login protocol. Likely it is NOT that simple. You will have to figure out how they do it, and find a compatible way if running them both at the same time. There's a good chance they either use cookies or sessions to store the validity of the user. Good luck!
*/

Open in new window

0
 
santockiAuthor Commented:
Thank you for the response. But it is not exactly what I needed. What I need to know is:

 I would like to send HTTP header codes to the second application's login page so it will be logged in, as if the user have inputted the username and the password via <FORM> tag (more like a bot logging in automatically for me, but all this happens in the background, so user will NOT be redirected to the second application). I don't want to use PHP's header() function.  This way, I don't have to include any functions from the second application (either SNS or Textpattern CMS). Is this even possible? Hope it makes sense.

Thank you.
0
 
santockiAuthor Commented:
Adding to the previous comment...

I have a Contact Form on my site and everyday I get the form message submitted by spam bots automatically. I am trying to make it work similar like that by sending user's username, password and IP info (the IP info means not sending a string, but it should be captured by $_SERVER['REMOTE_ADDR'] variable as if the visitor has physically visited the page for logging in ). Thank you.
0
 
Mahdii7Commented:
Ah I see, you can use curl for this. I don't have time to go over usage in detail right now, but I'll link you to a reference I've used in the past.

http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html

Good luck!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now