Events Manager
[resolved] JSON-API with Events Manager - querying for events (6 posts)

  1. Daedalon
    Posted 3 years ago #

    We're creating a mobile application that lets users access the data stored in the site by Events Manager. This also requires us to do a JSON interface. With the following code in my custom JSON-API controller I'm able to display the events that were added recently:

    public function get_recent_events() {
    	global $json_api;
    	// See also: http://codex.wordpress.org/Template_Tags/query_posts
    	$posts = $json_api->introspector->get_posts(array(
    		'post_type' => 'event'
    	return $this->posts_result($posts);

    The next step is to be able to limit the query to display only events which have a start date within the next 7 days. JSON-API's controllers can use all WordPress' usual methods of accessing data in custom tables, but I'm not yet familiar with them.

    What's the best way to query the IDs of all the events that start within the next 7 days?

  2. agelonwl
    Posted 3 years ago #

  3. Daedalon
    Posted 3 years ago #

    Thanks! I'll look into them.

  4. Daedalon
    Posted 3 years ago #

    Got it working by changing the code inside the function to

    global $json_api;
    		$scope = 'future';
    		$scope = $json_api->query->scope;
    		$posts = EM_Events::get( array('scope'=>$scope, 'owner'=>false) );
    		return $this->posts_result($posts);

    and creating a custom scope. Thanks, agelonwl!

  5. cianfro
    Posted 2 years ago #

    hello ...
    @Daedalon how to elaborate the JSON-API for reading the events manage ??

  6. Daedalon
    Posted 2 years ago #

    Cianfro: First you need to study how to create a controller in JSON-API. Then use the above code snippets to get the data from Events Manager.

    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic