Reputation: 1943
I want to make an application that will be receiving get requests and respond with xml. Here's the scenario:
User comes to site_a.com?site.phpid=abc, from there I have to make a GET request to site_b.com/checker.php?id=abc.
How to make a GET request without user leaving the page?
Inside checker.php I have to respond with xml depending on that id
if(isset($_GET['id'])){
if($_GET['id']=='abc'){
// respond with xml
}
}
and then is site.php I have to receive that xml.
Thanks!
Upvotes: 0
Views: 424
Reputation: 7204
You could use curl
.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://site_b.com/checker.php?id=' . $id);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec();
curl_close($ch);
Upvotes: 2
Reputation: 1179
The easist way, you could use file_get_contents:
//site.php?id=abc
$xmlResponse = file_get_contents("site_b.com/checker.php?id=abc");
But make sure allow_url_fopen
can be true.
http://php.net/manual/en/filesystem.configuration.php
Upvotes: 2