How to put your MINDBODY class schedule on your website

by Devin on February 22, 2014

Most MINDBODY businesses would like to display their class schedule on their website someplace. If you are using PHP you can use the follow the steps below to display your MINDBODY schedule on your own site and customize how it is displayed with HTML and CSS.

Checkout a copy of my PHP class that wraps the MINDBODY API from https://github.com/devincrossman/mindbody-php-api

In the examples folder there is a simple example of implementing a class schedule. Make sure you supply your API source credentials in the MB_API class or as an argument to the MB_API() constructor like

require_once 'MB_API.php';
$mb = new MB_API(array(
  'SourceName'=>'YourSourceName',
  'Password'=>'YourPassword',
  'SiteIDs'=>array('YourSiteID')
));

If you don’t have a sourcename and password you can sign up for the MINDBODY Partner Program here.

The example class schedule shows the upcoming classes for the the next 7 days by setting the StartDateTime and EndDateTime parameters. There are additional parameters you can include for instance if you want to specify a specific program or location. You can get a list of available programs or locations and their IDs by calling the SiteService’s GetPrograms and GetLocations methods. See the MINDBODY API documentation for more parameters and methods you can use.

$programs = $mb->GetPrograms(array('ScheduleType'=>'All', 'OnlineOnly'=>false));
$locations = $mb->GetLocations();

Then you can pass in an array of IDs for just the specific locations or programs you want to display in your class schedule.

$classes = $mb->GetClasses(array(
  'StartDateTime' => date('Y-m-d'), 
  'EndDateTime' => date('Y-m-d', strtotime('today + 7 days')),
  'LocationIDs' => array(1,3),
  'ProgramIDs' => array(1,6,9)
));

There is a lot of information returned about the classes and they won’t necessarily be in ordered chronologically. You can see what data is returned by dumping the return from $mb->GetClasses() with the print_r() function. Check the example from my repository for a function that will sort the data by date and start time.




11 comments

You rock. I wish I had noticed this right when you posted it. I just finished a schedule that took like 25 hours, using the FrozenFire Library. Installing this took five minutes. Lol.
The coding is more streamlined than mine.

by Mike iLL on March 5, 2014 at 5:32 pm. #

code to add so cancelled classes that have been cancelled will not display if HideCancel has been set to true:

[code]
foreach($classes as $class) {
if (($class[‘IsCanceled’] == ‘TRUE’) && ($class[‘HideCancel’] == ‘TRUE’))
{
continue; //skip this and moce to next iteration
}
[/code]

by Mike iLL on March 5, 2014 at 6:53 pm. #

I seriously need to buy you a beer for writing these articles. I tried the FrozenFire Library but was met with 10’s of hours of headaches. Your methods for utilizing the MindBody API makes it SUUUUPER easy for someone who has never used SOAP before. I’ve learned a lot from what you have written and I am eternally grateful.

by Michael Large on March 6, 2014 at 6:32 pm. #

I’m using your wonderful Mindbody API as part of a wordpress plugin I’m developing, but right now I’m only able to make it work if I change the sourceCredentials array in the MB_API to a public variable.

Do you know of a way that the API could be used without actually changing the source file? I would love to use your original file as a dependency.

by Mike iLL on April 14, 2014 at 7:39 pm. #

I think that the answer is either in creating a sub-class, OR in adding a Setter to the class: http://www.php.net/manual/en/language.oop5.overloading.php#object.set.

Will report back…

by Mike iLL on April 15, 2014 at 5:19 pm. #

class my_MB_API extends MB_API {
protected $sourceCredentials = array(
"SourceName"=>'REPLACE_WITH_YOUR_SOURCENAME',
"Password"=>'REPLACE_WITH_YOUR_PASSWORD',
"SiteIDs"=>array('REPLACE_WITH_YOUR_SITE_ID')
);

function __construct($sourceCredentials = array())
{
parent::__construct();
}

public function setCreds($sourceCredentials)
{
$this->sourceCredentials = $sourceCredentials;
}

}

by Mike iLL on April 20, 2014 at 8:43 am. #

Hey Devin, this is fantastic. I had a 0_4 version created and with the recent deprecation of that version, I can’t get my class schedule to work now…various Fatal errors. I don’t code and the person who originally wrote the PHP is no where to be found. Any chance you are available to consult/contract to fix our problem?

by Ric on May 29, 2014 at 2:03 am. #

Hi Devin do you have an email where I may contact you?
I have a development need with mindbody online and was curious if you were available. I’d like to explain more.

Thanks
Mark

by Mark white on October 19, 2014 at 10:37 pm. #

Sorry Mark I just saw this. I don’t have a lot of time for new projects right now but you can email me the details of your development needs at devin@devincrossman.com and I’ll see if there’s anything I can do

by Devin on October 30, 2014 at 2:02 am. #

Hi mark,

it showing me error as
The supplied username and password combination are incorrect.
please help me, what should i have to put in the input box and where they create account after signup.

thank you in advance.

by Prasad on January 5, 2016 at 1:32 pm. #

Is there a working example of this LIVE on the web I can check out somewhere?

I tried using HealCode to embed a MINDBODY widget on my site but they only let you show 1 week of data at a time.

Since we operate 1 class per week, I want to be able to show a list with classes for the next month.

Hoping this can be our solution!

by Victor Mathieux on September 15, 2016 at 10:12 pm. #