json pull to insert into a post
-
Hello,
I’ve got a handle on the non Worspress PHP (I’ve been experimenting in PHPfiddle.org) but am having trouble translating it to functionality in wordpress.
I’m looking to get a json pull from http://aggrenda.com/mpellas/michael-pellas/events.json and post the data (address, description, photo url, website) in a scheduled wordpress post.
I’ve been able to get a json string but haven’t been able to parse it in wordpress.
here is the latest code:
add_shortcode('aggrenda', 'requestAggrendaEvents'); function requestAggrendaEvents() { $json = wp_remote_get("http://aggrenda.com/mpellas/michael-pellas/events.json"); $data = json_decode($json, true); return $data['events']; } function getPostInfo($aggrendaEvent) { return array( "title" => $aggrendaEvent['title'], "description" => $aggrendaEvent['description'], ); } // Get the aggrenda events as an associative array $aggrendaEvents = requestAggrendaEvents(); // Get the WordPress post information for the "next" event in Aggrenda $postInfo = getPostInfo($aggrendaEvents[0]); // TODO: Create a post using $postInfo echo $postInfo['title'], ''; echo $postInfo['description'], ''; // See what exactly is in $postInfo right now var_dump($postInfo);What am I missing?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘json pull to insert into a post’ is closed to new replies.