I would like to send a xml response when a url is hit with parameters like http://gmail.com/cb/send/send.php?user_name=admin1&password=test123&subscriber_no=1830070547&mask=Peter&sms=‘Test SMS’
When one will hit this link then a response will be given which will like
public function sendResponse($type,$cause) {
$response = '<?xml version="1.0" encoding="utf-8"?>';
$response = $response.'<response><status>'.$type.'</status>';
$response = $response.'<remarks>'.$cause.'</remarks></response>';
return $response;
}
I am calling this method from my controller file and just echo the value.
will the hitter will get this response?
<?php
......
......
echo $sendResponse($type,$cause);
?>
Will user will get resonse by this echo?
returnalone won’t sending anything to the client. If you are echoing the result ofsendResponse()then yes, the client will receive the XML:Notice I removed the
$from the sendResponse call – PHP will assume it’s a variable if you use the$.It’s recommended to add a header to tell the client that XML is being sent and the encoding, but it’s not essential for the transport of the XML:
You can use the concatenation character
.after you declared the XML header: