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
PHP Website communication with other Website
Moderator: General Moderators
-
phpthebest
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 21, 2006 9:23 am
- Location: London
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.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.
-
phpthebest
- Forum Newbie
- Posts: 2
- Joined: Fri Jul 21, 2006 9:23 am
- Location: London
Thanks for the quick reply.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.
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.
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..
..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.
Code: Select all
<?php
$user = $_POST['user'];
$pass = $_POST['pass'];
if ($user=="Womble" && $pass=="wimbledon") {
echo "Yes";
} else {
echo "No";
}
?>It's exactly the same as any normal browser request as far as he's concerned.