[英]How to retrieve value from this object?
Using php, I trying to get a particular coupon. 使用php,我尝试获取特定优惠券。
require_once './lib/Stripe.php';
Stripe::setApiKey(STRIPE_SK);
$response = Stripe_Coupon::retrieve('coupon id here');
print_r($response);
print_r($response); print_r($ response); gave me the object below.
给了我下面的物体。 My question is how can retrieve the [id] from the object?
我的问题是如何从对象中检索[id]? Thanks for helping
感谢您的帮助
Stripe_Coupon Object
(
[_apiKey:protected] => sk_test_xxxxxxxxxxxxxxxxxxxxxxxxxxx
[_values:protected] => Array
(
[id] => 10percent
[created] => 1395914393
[percent_off] => 10
[amount_off] =>
[currency] =>
[object] => coupon
[livemode] =>
[duration] => repeating
[redeem_by] =>
[max_redemptions] =>
[times_redeemed] => 2
[duration_in_months] => 12
[valid] => 1
)
)
The object is using the PHP magic __get method. 该对象正在使用PHP魔术__get方法。 You should just be able to use:
您应该可以使用:
$id = $response->id;
If you go through source you see the object eventually comes down to the Stripe_Object class. 如果遍历源代码,您会看到对象最终归结为Stripe_Object类。 Source here: https://github.com/stripe/stripe-php/blob/master/lib/Stripe/Object.php
来源在这里: https : //github.com/stripe/stripe-php/blob/master/lib/Stripe/Object.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.