响应表单API和工作在php


Response form API and working with in php

我有一个来自API Web服务的响应,我想获得这个对象的值。示例:TimeStamp,TransactionID,SubscriptionResponse

并在HTML代码中显示不同的DIV值。如何获得这个值和工作的主题??

API的响应:

object(SubscriptionResponseContainer)#11 (5) { 
    ["Timestamp":protected]=> string(25) "2015-09-15T04:30:00+04:30"        
    ["TransactionId":protected]=> string(10) "1445756101" 
    ["SubscriptionResponse":protected]=> array(1) { 
        [0]=> object(SubscriptionResponseItemCollection)#12 (2) {    
            ["Activate":protected]=> NULL 
            ["Renew":protected]=> NULL 
        } 
    } 
    ["SubscriptionError":protected]=> array(1) { 
        [0]=> object(SubscriptionResponseErrorCollection)#13 (2) { 
            ["ActivateError":protected]=> array(1) { 
                [0]=> object(ResponseItemErrorType)#14 (4) { 
                    ["UnitId":protected]=> int(1) 
                    ["SubscriberId":protected]=> string(11) "09394354387" 
                    ["ErrorCode":protected]=> int(1)   
                    ["ErrorMessage":protected]=> string(70) "SubscriberId specified in the activate order was previously activated." 
                } 
            } 
            ["RenewError":protected]=> NULL 
        } 
    } 
    ["TransactionError":protected]=> NULL 
} 

例如:

$timestamp=$result['Timestamp'];
$TransactionID=$result['Timestamp']['TransactionID'];

您可以这样做:$obj->Timestamp

或转换为数组:

$array = get_object_vars($obj);