So I've been learning some more, but still need help. I think my trouble is with nesting. I wrote my own short code and did this:
//Test code for json parsing
function test_func( $atts ){
$json = file_get_contents('https://affiliate.creditkarma.com/api/v1/offers/card/CCAmericanExpressCard54-json?pubKey=JIA7EF9VEK5X0R5J');
$obj = json_decode($json);
return $obj ->{'status'};
}
add_shortcode( 'testcode', 'test_func' );
When I put "[testcode]" on a post, I get "SUCCESS" back which is what is stored under "status" on the json page. So far, so good. Now I try to access more interesting information that is nested in there. I have tried:
return $obj ->{'header.name'};
return $obj ->{'name'};
return $obj ->{'header(name)'};
return $obj ->{'header('name')'};
return $obj ->{'header[name]'};
none of which worked. I feel I am so close and just need help formatting the key. I realized I was having the same issue with the short-code plugin. when I just put "status" in as the key it worked fine.