Hilfe, ich kann die Lösung hier nicht finden, Suche ist keine Hilfe, also habe ich beschlossen, eine Frage hier zu stellen.So erhalten Sie die Daten in Objekt: Liste, Daten
<?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);
?>
Meine Frage ist, wie Sie die ID bekommen? Ich möchte nur die ID bekommen. Wie kann ich darauf zugreifen? Ich habe auch das Gefühl, dass etwas mit meinem Code nicht stimmt, bitte helfen und korrigieren.
{
"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"
}
},
nach dem Entfernen von json_encode ($ output, true); das Ergebnis ist
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
)
)
für Id bekommen verwenden 'echo $ a [ "Daten"] [0] [id];' –