Enjin API (JSON) to PHP part 2 -


i'm trying figure out how data http://www.natomilcorp.com/api/get-tags

but doesn't work way working http://www.natomilcorp.com/api/get-users

<?php  $content = file_get_contents('http://natomilcorp.com/api/get-tags'); $array = json_decode($content, true);   foreach ($array $key => $value) {  }  ?> 

should return : major

there's id rank + id of each user rank. how that?

  • data i'm trying get.

array ( [tags] => array ( [766910] => array ( [name] => major [visible] => 2 [users] => array ( [0] => 200159 ) ) [766912] => array ( [name] => captain [visible] => 2 [users] => array ( [0] => 2261591 ) ) [766913] => array ( [name] => 1st lieutenant [visible] => 2 [users] => array ( [0] => 9054053 ) ) [766914] => array ( [name] => 2nd lieutenant [visible] => 2 [users] => array ( [0] => 8987889 ) ) [773490] => array ( [name] => sergeant first class [visible] => 2 [users] => array ( [0] => 7725577 ) ) [773492] => array ( [name] => sergeant [visible] => 1 [users] => array ( [0] => 1060956 [1] => 7302252 [2] => 8757300 [3] => 8863799 [4] => 8965561 [5] => 9261041 ) ) [773493] => array ( [name] => corporal [visible] => 2 [users] => array ( [0] => 3021405 [1] => 7007387 [2] => 9139763 [3] => 9213371 ) ) [773494] => array ( [name] => private first class [visible] => 2 [users] => array ( [0] => 2200849 [1] => 3641961 [2] => 9178511 [3] => 9261322 [4] => 9323849 [5] => 9389371 [6] => 9430088 ) ) [773495] => array ( [name] => private [visible] => 2 [users] => array ( [0] => 114357 [1] => 261041 [2] => 304466 [3] => 549312 [4] => 1118346 [5] => 1710685 [6] => 2141867 [7] => 3211667 [8] => 3310027 [9] => 3553805 [10] => 4528862 [11] => 7379434 [12] => 8403949 [13] => 8428123 [14] => 8650774 [15] => 8910960 [16] => 9010718 [17] => 9141940 [18] => 9223268 [19] => 9276028 [20] => 9308336 [21] => 9324049 [22] => 9343007 [23] => 9379991 [24] => 9388650 [25] => 9388744 [26] => 9501913 ) ) [773499] => array ( [name] => recruit [visible] => 2 [users] => array ( [0] => 89975 [1] => 205838 [2] => 384035 [3] => 1607344 [4] => 3131066 [5] => 6461552 [6] => 7126984 [7] => 7233456 [8] => 8594187 [9] => 9210020 [10] => 9319294 [11] => 9324467 [12] => 9368201 [13] => 9401020 [14] => 9401208 [15] => 9411271 [16] => 9412511 [17] => 9442152 [18] => 9472151 [19] => 9481048 [20] => 9507716 [21] => 9519155 [22] => 9519665 [23] => 9524202 [24] => 9524528 [25] => 9527256 [26] => 9528148 [27] => 9528464 [28] => 9532974 [29] => 9532993 ) ) [794713] => array ( [name] => nmc member [visible] => 0 [users] => array ( [0] => 89975 [1] => 114357 [2] => 200159 [3] => 205838 [4] => 304466 [5] => 384035 [6] => 549312 [7] => 857679 [8] => 870831 [9] => 1060956 [10] => 1118346 [11] => 1607344 [12] => 1710685 [13] => 2141867 [14] => 2200849 [15] => 2261591 [16] => 3021405 [17] => 3131066 [18] => 3211667 [19] => 3310027 [20] => 3553805 [21] => 3641961 [22] => 4528862 [23] => 5888412 [24] => 6461552 [25] => 7007387 [26] => 7126984 [27] => 7233456 [28] => 7302252 [29] => 7379434 [30] => 7725577 [31] => 8403949 [32] => 8428123 [33] => 8594187 [34] => 8650774 [35] => 8757300 [36] => 8863799 [37] => 8910960 [38] => 8965561 [39] => 8987889 [40] => 9010718 [41] => 9017629 [42] => 9054053 [43] => 9139763 [44] => 9141940 [45] => 9178511 [46] => 9210020 [47] => 9213371 [48] => 9223268 [49] => 9261041 [50] => 9261322 [51] => 9276028 [52] => 9289688 [53] => 9308336 [54] => 9319294 [55] => 9323849 [56] => 9324049 [57] => 9324467 [58] => 9343007 [59] => 9361657 [60] => 9368201 [61] => 9379991 [62] => 9388650 [63] => 9388744 [64] => 9389371 [65] => 9401020 [66] => 9401208 [67] => 9411271 [68] => 9412511 [69] => 9430088 [70] => 9442152 [71] => 9472151 [72] => 9481048 [73] => 9501913 [74] => 9507716 [75] => 9519155 [76] => 9519665 [77] => 9524202 [78] => 9524528 [79] => 9527256 [80] => 9528148 [81] => 9528464 [82] => 9532974 [83] => 9532993 ) ) [905780] => array ( [name] => reserve / inactive [visible] => 2 [users] => array ( [0] => 1116431 [1] => 1146450 [2] => 1327008 [3] => 3488556 [4] => 4057254 [5] => 4109011 [6] => 4442271 [7] => 5075797 [8] => 6348486 [9] => 6727549 [10] => 7482138 [11] => 7669434 [12] => 7810956 [13] => 7813040 [14] => 7845349 [15] => 7873320 [16] => 8163829 [17] => 8610931 [18] => 8720229 [19] => 8758932 [20] => 8944586 [21] => 8988410 [22] => 9009221 [23] => 9016644 [24] => 9143121 ) ) [916781] => array ( [name] => high command [visible] => 2 [users] => array ( [0] => 192868 ) ) [950454] => array ( [name] => (af) 2nd lieutenant [visible] => 2 [users] => array ( [0] => 870831 [1] => 5888412 [2] => 9017629 [3] => 9289688 [4] => 9361657 ) ) [950472] => array ( [name] => (af) 1st lieutenant [visible] => 2 [users] => array ( [0] => 857679 ) ) [964515] => array ( [name] => 8 week service ribbon 1a [visible] => 2 [users] => array ( [0] => 857679 [1] => 3021405 [2] => 8428123 ) ) [964541] => array ( [name] => 8 week service ribbon 2a [visible] => 2 [users] => array ( [0] => 7725577 ) ) [964552] => array ( [name] => 8 week service ribbon 4a [visible] => 2 [users] => array ( [0] => 200159 ) ) [964580] => array ( [name] => altis war service ribbon [visible] => 2 [users] => array ( [0] => 200159 [1] => 857679 [2] => 870831 [3] => 1060956 [4] => 2261591 [5] => 5888412 [6] => 7302252 [7] => 7725577 [8] => 8757300 [9] => 8863799 [10] => 8965561 [11] => 9054053 ) ) [964632] => array ( [name] => commanding officers commendation [visible] => 2 [users] => array ( [0] => 2261591 [1] => 9054053 [2] => 9139763 [3] => 9261322 ) ) [964807] => array ( [name] => executive officers commendation [visible] => 2 [users] => array ( [0] => 5888412 [1] => 8863799 [2] => 9017629 ) )

it should

echo $array['tags'][$key]['name']; 

you see there tags key , need add while accessing.

working code..

<?php $content = file_get_contents('http://natomilcorp.com/api/get-tags'); $array = json_decode($content, true); $key = "766910"; echo $array['tags'][$key]['name']; 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -