解析affiliateservice api响应
我通过 affiliateservice api 获取 TransactionList。 我的 print_r($response) 给了我这个(我必须输入 xx 但实际上那里有数字):
stdClass Object
(
[getTransactionListReturn] => Array
(
[0] => stdClass Object
(
[iId] => xx
[sStatus] => pending
[sType] => normal
[sIp] => xx
[bPaid] => xx
[iPaymentId] => xx
[iMerchantId] => xx
[fSaleAmount] => xx
[fCommissionAmount] => xx
[dClickDate] => xx
[dTransactionDate] => xx
[sClickref] => xx
[aTransactionParts] => Array
(
[0] => stdClass Object
(
[sCommissionGroupName] => STANDARD
[fSaleAmount] => xx
[fCommissionAmount] => xx
[iCommission] => xx
[sCommissionType] => percentage
)
)
)
[1] => stdClass Object
(
[iId] => x
[sStatus] => pending
[sType] => normal
[sIp] => x
[bPaid] =>
[iPaymentId] => x
[iMerchantId] => x
[fSaleAmount] => x
[fCommissionAmount] => x
[dClickDate] => x
[dTransactionDate] => x
[sClickref] => x
[sSearchSiteName] => x
[sSearchSiteKeyword] => x
[aTransactionParts] => Array
(
[0] => stdClass Object
(
[sCommissionGroupName] => DEFAULT
[fSaleAmount] => x
[fCommissionAmount] => x
[iCommission] => x
[sCommissionType] => percentage
)
)
)
)
[getTransactionListCountReturn] => stdClass Object
(
[iRowsReturned] => 2
[iRowsAvailable] => 386
)
)
那么,我的问题是如何在 PHP 中“解析”这个?我的意思是我如何访问这些数据?我的意思是像
$response[0]->sStatus;
谢谢你的帮助!
I am fetching the TransactionList through affiliateservice api.
My print_r($response) gives me this (I had to put xx but actually there are numbers there):
stdClass Object
(
[getTransactionListReturn] => Array
(
[0] => stdClass Object
(
[iId] => xx
[sStatus] => pending
[sType] => normal
[sIp] => xx
[bPaid] => xx
[iPaymentId] => xx
[iMerchantId] => xx
[fSaleAmount] => xx
[fCommissionAmount] => xx
[dClickDate] => xx
[dTransactionDate] => xx
[sClickref] => xx
[aTransactionParts] => Array
(
[0] => stdClass Object
(
[sCommissionGroupName] => STANDARD
[fSaleAmount] => xx
[fCommissionAmount] => xx
[iCommission] => xx
[sCommissionType] => percentage
)
)
)
[1] => stdClass Object
(
[iId] => x
[sStatus] => pending
[sType] => normal
[sIp] => x
[bPaid] =>
[iPaymentId] => x
[iMerchantId] => x
[fSaleAmount] => x
[fCommissionAmount] => x
[dClickDate] => x
[dTransactionDate] => x
[sClickref] => x
[sSearchSiteName] => x
[sSearchSiteKeyword] => x
[aTransactionParts] => Array
(
[0] => stdClass Object
(
[sCommissionGroupName] => DEFAULT
[fSaleAmount] => x
[fCommissionAmount] => x
[iCommission] => x
[sCommissionType] => percentage
)
)
)
)
[getTransactionListCountReturn] => stdClass Object
(
[iRowsReturned] => 2
[iRowsAvailable] => 386
)
)
So, my question is how can I "parse" this in PHP? I mean how can I access these data? I mean something like
$response[0]->sStatus;
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一切都是
stdClass
的实例,这是 PHP 中的标准类(当然,数组除外:))。这意味着您将使用
->
来访问每个对象的属性。您可能是通过使用 json_decode() 得到的。如果您更愿意处理数组而不是对象,可以将第二个参数设置为
true
。Everything is an instance of the
stdClass
, the standard class in PHP (except for the arrays, of course :)).This means you would use
->
to access the properties of each object.You probably got this from using
json_decode()
. You can set the second parameter totrue
if you'd rather deal with arrays than objects.好吧,首先是对象,然后是数组,然后又是带有一些值的对象。
我会选择这样的东西:
应该有效。
Well, the first thing is object, than it's array, than it's object again with some values.
I would go for something like this:
Should work.