JSON and callback

Parse a JSON URL source (http://ip.jsontest.com/) using a custom callback function

[wpws url='http://ip.jsontest.com/' basehref=0 callback='json_parser_callback']
This is a sample callback function that needs to be placed into functions.php of your child theme:
function json_parser_callback($content){
   $object = json_decode(trim($content));
   return $object->ip;
}

<?php echo wpws_get_content(‘http://ip.jsontest.com/’, ”, array(‘basehref’ => 0, ‘callback’ => ‘json_parser_callback’)); ?>
50.87.248.113

Leave a Reply