How to call external URL and print response


Sending the data of one page to another, Sending the data of one page to another and printing response, Call external URL and print response, How to send the data to another URL and print the response on the page, How to Call external UR's,

//  Getting the data from called page
// we can use GET method or POST method depends on the calling page
print_r($_GET )
$name = $_GET['name'];
$email = $_GET['email'];
$company = $_GET['company'];
$phone = $_GET['phone'];
$country = $_GET['country'];

// Encoding the values to URL
$name = urlencode($name);
$email = urlencode($email);
$company = urlencode($company);
$phone = urlencode($phone);
$country = urlencode($country);

// Sending the values to another URL
// it reads the entire file into string
$response = file_get_contents('http://websitename.com/finename.fileExtension?name='.$name.'&email='.$email.'&company='.$company.'&phone='.$phone.'&country='.$country.''');

// Printing the response
echo $response; 

Here is description of file_get_contents() function. Click here

Post a Comment

Analytics