Adding upcoming events to your website

Let Muzodo keep your website up-to-date.

Server Code

The following example is given in PHP but the principle is the same for any server side code. If you need help setting it up, contact us.

We suggest you proceed in the following way:

  1. Make a copy of the calendar/events page from your website.
  2. Insert the PHP code below and run it to see it work.
  3. Change the embedded HTML in the code below to use the same classes and styles as used on your website.

As you'll see in the logic below,

  • the code excludes unconfirmed and cancelled events. It also checks for and only includes public events.
    <!-------------------------NEW CODE START------------------------------------------->
    <h2><a name="performances">Upcoming Performances</a></h2>
    <?php
    	function get_url_contents($url){
    		$crl = curl_init();
    		$timeout = 5;
    		curl_setopt ($crl, CURLOPT_URL,$url);
    		curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
    		curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
    		$ret = curl_exec($crl);
    		curl_close($crl);
    		return $ret;
    	}
    
    	$apikey = "your group API key";
    	$url = "https://www.muzodo.com/api/v1/group/$apikey/events";
    	$events = json_decode(stripslashes(get_url_contents($url)));
    ?>
    
    <table class="performance">
    	<thead>
    		<tr>
    			<th class="performance-date">Date</th>
    			<th class="performance-location"><u>Performance</u></th>
    		</tr>
    	</thead>
    	<tbody>
    <? foreach ($events as $key => $event) {
          if ($event->Confirmed == 0 || $event->Cancelled == 1)
            continue;
    
    	  # Note: Private events have their address withheld by the API, 
    	  #       so you can show those events on your website too.
    	  #       Change this logic, per your requirements.
          if ($event->EventType != "PUBLIC" && $event->EventType != "PRIVATE")
            continue;
    ?>
    		<tr>
    			<td class="performance-date">
    				<? echo $event->FormattedDate . ", " . 
    					$event->FormattedPlayTime . "-" . 
    					$event->FormattedEndTime ?>
    			</td>
    			<td class="performance-location">
    				<?= $event->Name ?><br />
    				<?= $event->Address ?>
    			</td>
    		</tr>
    <? } ?>
    
    	</tbody>
    </table>
    
    <?php
    echo $muzodoWebWidget->getSchemas();
    
    # See http://schema.org/ for details. 
    # A schema is a machine readable format that
    # allows search engines to find details on your events.
    ?>
    <!-------------------------NEW CODE END------------------------------------------->
    

    API Fields

    See here for details on the fields that are available.