【发布时间】:2015-11-27 00:05:05
【问题描述】:
在 PHP 中使用 Stripe API 时,所有试图从中提取值的尝试都返回 null,r 根本不显示结果。我试过了
$customers = \Stripe\Customer::all();
$customers_json = $customers->__toJSON();
json_decode($customers_json);
echo $customers_json->data->id;
还有
$customers = \Stripe\Customer::all();
$customer = $customers->__toArray(true);
echo $customer["data"]["id"];
但每次都导致空白回声。但是,当我只输出原始变量而不将其解析为 JSON 或任何内容时,它会返回一个包含 JSON 值的字符串,只是未解析。原始$customers 的输出是
Stripe\Collection JSON: { "object": "list", "has_more": false, "url": "\/v1\/customers", "data": [ { "id": "cus_6u32tOQ6MRXuqm", "object": "customer", "created": 1441114587, "livemode": false, "description": "test customer", "email": "test@respice.xyz", "shipping": null, "delinquent": false, "metadata": [ ], "subscriptions": { "object": "list", "total_count": 0, "has_more": false, "url": "\/v1\/customers\/cus_6u32tOQ6MRXuqm\/subscriptions", "data": [ ] }, "discount": null, "account_balance": 0, "currency": null, "sources": { "object": "list", "total_count": 0, "has_more": false, "url": "\/v1\/customers\/cus_6u32tOQ6MRXuqm\/sources", "data": [ ] }, "default_source": null } ] }
【问题讨论】:
-
你能告诉我们
$customers的完整输出吗?
标签: php json runtime-error stripe-payments