PHP如何处理SOAP响应

时间:2014-08-20 08:05:24

标签: php soap wsdl

我需要检查if语句的结果

$client = new SoapClient("http://example.com/message.asmx?wsdl");
/* Set your parameters for the request */
$params = array(
    "recepient" => "$recipient",
    "short_message" => "$text",
    "message_id" => $smsid,
    "deadline" => $deadline,
    "user_id" => "$userid"
);

/* Invoke webservice method with your parameters, in this case: Function1 */
$response = $client->__soapCall("Standard", array($params));

var_dump($response);

我得到回应

object(stdClass)#3 (1) { ["StandardResult"]=> bool(true) }

如何编写if语句来检查StandardResult的值是否为true 如果我得到StandardResult作为' SENT'我怎么能用/得到那个? 我基本上想要:

if ($responce['StandardResult'] == true) {
    echo "Expectancy is met";
}

if ($responce['StandardResult'] == 'SENT') {
    echo "Expectancy is met";
}

1 个答案:

答案 0 :(得分:1)

这是一个对象,因此您可以访问属性访问权限。

if ($response->StandardResult) {
}