I am using soap api request and its returning me this response.
That's my laravel controller code.
public function testResponseSRI($phone, $code)
{
$url = 'https://tamimahsms.com/user/bulkpush.asmx?wsdl';
$body = '
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SendSMS xmlns="https://www.tamimahsms.com/">
<UserName>username</UserName>
<Password>password</Password>
<Message>test message with code '.$code.'</Message>
<Priority>1</Priority>
<Schdate>07/18/2018</Schdate>
<Sender>AsifSource</Sender>
<AppID>123456</AppID>
<SourceRef>7654321</SourceRef>
<MSISDNs>'.$phone.'</MSISDNs>
</SendSMS>
</soap:Body>
</soap:Envelope>';
$headers = ['Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($body)];
$result = SoapClientRequest::send($url, $headers, $body);
return response()->json($result);
}
I want to get <StatusCode>00</StatusCode>
from body
object.
How can I get this?
Thanks
Finally, I figured out. The response was not a regular JSON, firstly convert it:
$data = $jsonResponse->getData();
Then treat it as a regular json. Now I can easily get <StatusCode>00</StatusCode>
by using php preg_match
method like this:
if(preg_match("!<StatusCode>(.+)</StatusCode>!i",$data->body,$matches))
{
return $matches[1] // return 00
}