PHP Website communication with other Website

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpthebest
Forum Newbie
Posts: 2
Joined: Fri Jul 21, 2006 9:23 am
Location: London

PHP Website communication with other Website

Post by phpthebest »

Hi Everybody,

Does anyone know that how to communicate with otherwebsite. My website which is using PHP and MySQL, needs to communicate with other website.

The Other wibsite will need to send certain parameters, e.g. (username, password, code), my website will check for the information in the local database and send value back YES/NO (if code found again that username, password then yes otherwise no).

My question is how my website can efficiently handle this. Do I need to write some API if yes, any example, any hint.

I know other website will submit request to some URL on my website along with the parameters. My website will receive request and find the results from the database, Now how I need to send answer (YES/NO) back to otherwebsite efficiently?


Thanks
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could do this with cURL or XML.

I think for simplicity's sake, I'd pick cURL. one web site could post data to the other then deal with the response accordingly.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Pegleg Jackson wrote:you could do this with cURL or XML.

I think for simplicity's sake, I'd pick cURL. one web site could post data to the other then deal with the response accordingly.
If the other website is POSTing the data to phpthebest's site, then they'll be the ones using cURL, not phpthebest. His site just needs a normal PHP form handler.
phpthebest
Forum Newbie
Posts: 2
Joined: Fri Jul 21, 2006 9:23 am
Location: London

Post by phpthebest »

Pegleg Jackson wrote:you could do this with cURL or XML.


I think for simplicity's sake, I'd pick cURL. one web site could post data to the other then deal with the response accordingly.
Thanks for the quick reply.

As I know, if I use cURL, I need to send query string (YES/NO) to other websites URL.
e.g.

http://www.otherwebsiteabc.com/abc.php?answer=yes
http://www.otherwebsiteabc.com/abc.php?answer=no

So other website need to catch data from abc.php from parameters.



Is there any other way to handle that, e.g. otherwebsite/application call to my site as follows, and it will return result from my website (YES/No) to variable. Something as described below:

Other website/application send data to my website using some function and get result into get_answer.

get_answer = get_data(username, password, code);


Thanks.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you can post data using cURL. YOu don't have to send the params as $_GET params.

the alternative would be to use XML and have the servers reach out for new info vs pushing info from one another.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Why are people suggesting cURL? He'll only need cURL if he's pushing POST data out to the other site .. he isn't. The other site is POSTing data to a PHP script on his site, and he's returning text. Something as simple as..

Code: Select all

<?php

$user = $_POST['user'];
$pass = $_POST['pass'];

if ($user=="Womble" && $pass=="wimbledon") {
  echo "Yes";
} else {
  echo "No";
}

?>
..will work. Might need to do header("Content-type: text/plain"); at the top but that's not strictly necessary.

It's exactly the same as any normal browser request as far as he's concerned.
Post Reply