我从API获得响应作为JSON对象,下面是我得到的JSON对象。我试图从它访问一些字段,但不知何故,它不起作用。
我是API和JSON的新手,所以任何帮助都会很棒。
{
[
"result"
]=>object(stdClass)#5(17){
[
"id"
]=>string(32)"f3add916cd34d635cb88452f4b024028"[
"name"
]=>string(12)"domain.com"[
"status"
]=>string(7)"pending"[
"paused"
]=>bool(false)[
"type"
]=>string(4)"full"[
"development_mode"
]=>int(0)[
"name_servers"
]=>array(2){
[
0
]=>string(21)"asa.ns.cloudflare.com"[
1
]=>string(22)"gabe.ns.cloudflare.com"
}[
"original_name_servers"
]=>array(2){
[
0
]=>string(26)"dns1.registrar-servers.com"[
1
]=>string(26)"dns2.registrar-servers.com"
}[
"original_registrar"
]=>NULL[
"original_dnshost"
]=>NULL[
"modified_on"
]=>string(27)"2017-08-22T10:03:26.537122Z"[
"created_on"
]=>string(27)"2017-08-22T10:03:26.537122Z"[
"meta"
]=>object(stdClass)#6(6){
[
"step"
]=>int(4)[
"wildcard_proxiable"
]=>bool(false)[
"custom_certificate_quota"
]=>int(0)[
"page_rule_quota"
]=>int(3)[
"phishing_detected"
]=>bool(false)[
"multiple_railguns_allowed"
]=>bool(false)
}[
"owner"
]=>object(stdClass)#7(3){
[
"id"
]=>string(32)"a1a492e3c3345ff4c84a569838d56967"[
"type"
]=>string(4)"user"[
"email"
]=>string(20)"email.com"
}[
"account"
]=>object(stdClass)#8(1){
[
"id"
]=>string(32)"myID"
}[
"permissions"
]=>array(22){
[
0
]=>string(15)"#analytics:read"[
1
]=>string(9)"#app:edit"[
2
]=>string(13)"#billing:edit"[
3
]=>string(13)"#billing:read"[
4
]=>string(17)"#cache_purge:edit"[
5
]=>string(17)"#dns_records:edit"[
6
]=>string(17)"#dns_records:read"[
7
]=>string(8)"#lb:edit"[
8
]=>string(8)"#lb:read"[
9
]=>string(10)"#logs:read"[
10
]=>string(12)"#member:edit"[
11
]=>string(12)"#member:read"[
12
]=>string(18)"#organization:edit"[
13
]=>string(18)"#organization:read"[
14
]=>string(9)"#ssl:edit"[
15
]=>string(9)"#ssl:read"[
16
]=>string(9)"#waf:edit"[
17
]=>string(9)"#waf:read"[
18
]=>string(10)"#zone:edit"[
19
]=>string(10)"#zone:read"[
20
]=>string(19)"#zone_settings:edit"[
21
]=>string(19)"#zone_settings:read"
}[
"plan"
]=>object(stdClass)#9(10){
[
"id"
]=>string(32)"0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee"[
"name"
]=>string(12)"Free Website"[
"price"
]=>int(0)[
"currency"
]=>string(3)"USD"[
"frequency"
]=>string(0)""[
"is_subscribed"
]=>bool(true)[
"can_subscribe"
]=>bool(false)[
"legacy_id"
]=>string(4)"free"[
"legacy_discount"
]=>bool(false)[
"externally_managed"
]=>bool(false)
}
}[
"success"
]=>bool(true)[
"errors"
]=>array(0){
}[
"messages"
]=>array(0){
}
}
如何访问“结果”中的 ID 变量或两个名称服务器?
我试过这个,不行。
foreach($a as $b=>$c)
{
echo $b . "=" . $c;
echo "<br>";
}
$ a包含json对象。 请指导我正确的方向。