幫助,我找不到解決方案在這裏,搜索沒有幫助,所以我決定在這裏發佈一個問題。如何獲取對象內的數據:列表,數據
<?php
function httpGet($url)
{
$ch = curl_init();
$headers = array('Authorization: Bearer xxxxxxxxxxx');
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output=curl_exec($ch);
curl_close($ch);
$output = json_encode($output,true);
$output = json_decode($output,true);
return $output;
}
$a = httpGet("https://api.stripe.com/v1/customers");
echo'<pre>';
print_r($a);
?>
我的問題是如何獲得ID? 我只想要ID。我怎樣才能訪問它? 我也覺得他們的代碼有問題,請幫忙解決。
{
"object": "list",
"data": [
{
"id": "cus_AKIT4Rz6NHlKMa",
"object": "customer",
"account_balance": 0,
"created": 1490067687,
"currency": null,
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": "[email protected]",
"livemode": false,
"metadata": {},
"shipping": null,
"sources": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_AKIT4Rz6NHlKMa/sources"
},
"subscriptions": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_AKIT4Rz6NHlKMa/subscriptions"
}
},
{
"id": "cus_AKIP3muBIL95H0",
"object": "customer",
"account_balance": 0,
"created": 1490067468,
"currency": null,
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": null,
"livemode": false,
"metadata": {},
"shipping": null,
"sources": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_AKIP3muBIL95H0/sources"
},
"subscriptions": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_AKIP3muBIL95H0/subscriptions"
}
},
刪除json_encode($ output,true);結果是
Array
(
[object] => list
[data] => Array
(
[0] => Array
(
[id] => cus_AKIT4Rz6NHlKMa
[object] => customer
[account_balance] => 0
[created] => 1490067687
[currency] =>
[default_source] =>
[delinquent] =>
[description] =>
[discount] =>
[email] => [email protected]
[livemode] =>
[metadata] => Array
(
)
[shipping] =>
[sources] => Array
(
[object] => list
[data] => Array
(
)
[has_more] =>
[total_count] => 0
[url] => /v1/customers/cus_AKIT4Rz6NHlKMa/sources
)
[subscriptions] => Array
(
[object] => list
[data] => Array
(
)
[has_more] =>
[total_count] => 0
[url] => /v1/customers/cus_AKIT4Rz6NHlKMa/subscriptions
)
)
用於獲取標識使用'回聲$一[ 「數據」] [0] [ID];使用數據' –