Start using the MINDBODY API in under 30 minutes using PHP

by Devin on August 27, 2012

Whether this is your first time developing with an API or not, you might have some trouble when you want to begin interacting with your MINDBODY data. I have created a simple guide will help you understand how the MINDBODY API works and how you can incorporate your MINDBODY business data on your own website using PHP.

How to prepare

You will need to have a web server running PHP with the SOAP extension installed and enabled. This can be a local development server setup (MAMP, WAMP) or an online server such as Digital Ocean who offer easy to manage VPS starting at $5/month.

Get your MINDBODY API credentials

Before you can start integrating your MINDBODY data you will need credentials to access the MINDBODY API. If you are just developing for a single business, follow the steps below. If you want to access the data for more than one business you will need to contact MINDBODY directly for this information.

  1. Complete the sign up form at the MINDBODY Partner Program website and write down your sourcename and key.
  2. This next step can be tricky. You have to make a call to the SiteService on the MINDBODY SOAP server to get an activation code. I made a form you can fill out instead. (UPDATE: MINDBODY has included this tool on the partner program website) You need the sourcename and key that you wrote down in the first step as well as your site id. If you don’t know what your site id is, log in to your MINDBODY account and check the URL. Your site id comes after “?studioid=” at the end of the URL.
  3. Give the activation link and code to the person with the ‘owner’ account for the MINDBODY site you want to access the data of.

Some API methods require user credentials as well. Set up a user for your application by following these steps.

  1. Log in to MINDBODY
  2. Go to Toolbox -> Setup -> Staff -> Staff Management
  3. Click Add New Staff Member

    Add New Staff Member

    Click on “Add New Staff Member”

  4. Enter something for the first and last name. I used first name “web” last name “developer”.
  5. Create a staff login with a new username and password and write these down.

    MINDBODY create staff log in

    Create a staff log in

  6. Save your new staff member.

The very basics of SOAP

SOAP is a platform independent protocol for exchanging information between websites. It’s fairly simple and easy to use once you understand how SOAP works. In your situation you want to access your data stored on MINDBODY’s servers. MINDBODY has provided a SOAP server that you can send XML formatted messages to and receive responses from over the http protocol.

Your SOAP messages are written in XML which is a markup language similar to HTML. Luckily using PHP we can abstract away the need to interact with the XML directly so it should make it a lot easier to work with.

The API Docs

You need to know where to send your SOAP requests. In SOAP jargon these destinations are known as endpoints. You can find the endpoints here http://www.mindbodyonline.com/api
Links to MINDBODY API services
Appointment Service
https://api.mindbodyonline.com/0_5/AppointmentService.asmx
Class Service:
https://api.mindbodyonline.com/0_5/ClassService.asmx
Client Service:
https://api.mindbodyonline.com/0_5/ClientService.asmx
Site Service:
https://api.mindbodyonline.com/0_5/SiteService.asmx
Sale Service:
https://api.mindbodyonline.com/0_5/SaleService.asmx
Staff Service:
https://api.mindbodyonline.com/0_5/StaffService.asmx
Data Service:
https://api.mindbodyonline.com/0_5/DataService.asmx

For the purposes of this tutorial we will be consuming the GetClasses method of the Class Service. You can browse the different service definitions and their methods here http://api.mindbodyonline.com/Doc




Creating the MINDBODY_API class

Update: I have created an updated version of this class that you can see at https://github.com/devincrossman/mindbody-php-api.

Now we’re going to create a PHP class to interface with MINDBODY that we can reuse easily in different projects. Open your code editor and create a new PHP document called MINDBODY_API_v0.5.php.

Due to a DDoS attack API requests now require a User-Agent header so the first thing we will do is set the user agent string with the following function

ini_set("user_agent", "FOOBAR");

include this at the top of the MINDBODYAPI_v0.5.php file. If you have the Zend Framework you can take advantage of it’s more robust SOAP classes but it is not a requirement for this project. If you don’t have PHP5 running I recommend using the nuSOAP library for PHP4. If you have PHP5 on your server you can use the native SoapClient class.

Now create the MINDBODY_API_v0.5 class

class MINDBODY_API {

}

Let’s also create some default properties. Inside the MINDBODY_API_v0.5 class add the following code. Substitute your source credentials and user credentials where indicated.

private $client;
private $sourceCredentials = array("SourceName"=>'{SourceName}', "Password"=>'{Password}', "SiteIDs"=>array('{SiteID}'));
private $userCredentials = array("Username"=>'{Username}', "Password"=>'{Password}', "SiteIDs"=>array('{SiteID}'));

We are defining the private variable $client at this scope level so that we can use it in some separate methods for debugging later.

Just a little more SOAP stuff

Now you need to know a little bit more about SOAP and specifically about something called the WSDL. Simply, a WSDL is an XML file that describes a web service. It lists the different methods exposed by a web service, their endpoints, and data types. All you need to know for now is that for MINDBODY the WSDL will be the endpoint url plus “?WSDL” in the query string. For example
https://api.mindbodyonline.com/0_5/ClassService.asmx?WSDL

The getClasses function

Our first attempt should be something easy so we know that our code is working. We’re going to call the GetClasses method of the Class service with no parameters (except our credentials) and it will return information on today’s classes. Understanding how to write this function will help you to write similar functions for other MINDBODY SOAP methods.

Create the following functions in the MINDBODY_API class:

function getClasses($params = array()) {
	$this->client = new SoapClient('https://api.mindbodyonline.com/0_5/ClassService.asmx?WSDL', array("soap_version"=>SOAP_1_1, 'trace'=>true));
	$request = array_merge(array("SourceCredentials"=>$this->sourceCredentials, "UserCredentials"=>$this->userCredentials),$params);
	try {
		$result = $this->client->GetClasses(array("Request"=>$request));
	} catch (SoapFault $s) {
    		echo 'ERROR: [' . $s->faultcode . '] ' . $s->faultstring;
	} catch (Exception $e) {
    		echo 'ERROR: ' . $e->getMessage();
	}
	return $result;
}

function getXMLRequest() {
	return $this->client->__getLastRequest();
}
	
function getXMLResponse() {
	return $this->client->__getLastResponse();
}

The getClasses method accepts one parameter, $params, which can be an array of options to pass to the web service method. If $params is not set it will default to an empty array. You create the SoapClient by passing the WSDL URI, and an optional array of settings. We must set the soap version to 1.1 in order for it to work with MINDBODY and setting trace to true will allow us to use the __getLastRequest() and __getLastResponse() methods.

Calling the getClasses function

You should now have the basic code you need to communicate with MINDBODY’s API. Create a new file and copy this last bit of code into it.

getClasses();
?>

When you view this page in your browser you will see a <textarea> with the XML code that was generated and sent to MINDBODY and the XML code that you received back. You can use a free XML formatting tool to clean up the formatting so it’s easier to read. This can be useful for diagnostic purposes and seeing the hierarchy of the data.

Passing options to getClasses

Instead of getting classes for today’s date, perhaps you want to get classes for a specific date. You can pass an array of options to the getClasses method. To find out what options are available you will have to check the MINDBODY API docs. For example: to get all of the classes for tomorrow you would use the following code.

$tomorrow,
		"EndDateTime"=>$tomorrow
	);
	$mbResult = $mb->getClasses($params);
?>



Targeting specific data

If you want to address specific information you can use PHP’s object access syntax. The following code lists the names of today’s classes.

foreach($mbResult->GetClassesResult->Classes->Class as $class) {
	echo $class->ClassDescription->Name.'
'; }

Using the MINDBODY API over SSL

Sometimes MINDBODY requires you to call a SOAP method over SSL. In order to do this you have to change the endpoint to begin with https:// One example of when you might need to do this is if you want to update a client’s credit card number. Change the endpoint when you instantiate the PHP SoapClient like this:

$this->client = new SoapClient('https://api.mindbodyonline.com/0_5/ClientService.asmx?WSDL', array("soap_version"=>SOAP_1_1,'location'=>'https://api.mindbodyonline.com/0_5/ClientService.asmx', 'trace'=>true));

Final Code

Trying to figure this all out for the first time can be frustrating. Hopefully this brief introduction has taught you enough that you can start developing with the MINDBODY API straight away. If you have any questions or suggested improvements, let me know in the comments section.

The final code for your MINDBODY_API_v0.5.php file could look like something like this:

ini_set("user_agent", "FOOBAR");
class MindBody_API {
	protected $client;
	protected $sourceCredentials = array("SourceName"=>'YourSourcenameHere', "Password"=>'YourPasswordHere', "SiteIDs"=>array('YourSiteIDHere'));
	protected $userCredentials = array("Username"=>'YourUsernameHere', "Password"=>'YourPasswordHere', "SiteIDs"=>array('YourSiteIDHere'));
	
	// CLIENT SERVICE //
	
	function addOrUpdateClients($params) {
		$this->client = new SoapClient('https://api.mindbodyonline.com/0_5/ClientService.asmx?WSDL', array("soap_version"=>SOAP_1_1,'location'=>'https://api.mindbodyonline.com/0_5/ClientService.asmx', 'trace'=>true));
		$request = array_merge(array("SourceCredentials"=>$this->sourceCredentials, "UserCredentials"=>$this->userCredentials),$params);
		try {
			$result = $this->client->AddOrUpdateClients(array("Request"=>$request));
		} catch (SoapFault $s) {
	    	echo 'ERROR: [' . $s->faultcode . '] ' . $s->faultstring;
		} catch (Exception $e) {
	    	echo 'ERROR: ' . $e->getMessage();
		}
		return $result;
	}
	
	function getClients($params) {
		$this->client = new SoapClient('https://api.mindbodyonline.com/0_5/ClientService.asmx?WSDL', array("soap_version"=>SOAP_1_1, 'trace'=>true));
		$request = array_merge(array("SourceCredentials"=>$this->sourceCredentials, "UserCredentials"=>$this->userCredentials),$params);
		try {
			$result = $this->client->GetClients(array("Request"=>$request));
		} catch (SoapFault $s) {
	    	echo 'ERROR: [' . $s->faultcode . '] ' . $s->faultstring;
		} catch (Exception $e) {
	    	echo 'ERROR: ' . $e->getMessage();
		}
		return $result;
	}
	
	
	// CLASS SERVICE //
	
	function getClasses($params = array()) {
		$this->client = new SoapClient('https://api.mindbodyonline.com/0_5/ClassService.asmx?WSDL', array("soap_version"=>SOAP_1_1, 'trace'=>true));
		$request = array_merge(array("SourceCredentials"=>$this->sourceCredentials, "UserCredentials"=>$this->userCredentials),$params);
		try {
			$result = $this->client->GetClasses(array("Request"=>$request));
		} catch (SoapFault $s) {
	    	echo 'ERROR: [' . $s->faultcode . '] ' . $s->faultstring;
		} catch (Exception $e) {
	    	echo 'ERROR: ' . $e->getMessage();
		}
		return $result;
	}
	
	function getXMLRequest() {
		return $this->client->__getLastRequest();
	}
	
	function getXMLResponse() {
		return $this->client->__getLastResponse();
	}
	
}



85 comments

This is very helpful, thanks for a great post.

Do you have an example on how to pass in parameters to the getClass method? I’m having trouble finding relevant information in the MindBody Docs.

by andrew on August 30, 2012 at 4:55 pm. #

Hey Andrew I’m glad you found it useful. I added an example on how to call the GetClasses method with parameters. To find out what the parameters are named you will have to check the MINDBODY docs.

by Devin on August 30, 2012 at 5:46 pm. #

Thanks a lot Devin.

I’ve been able to get some things working and have posted another example in a gist for anybody out there that wants to look.

This prints the name of class and the staff member associated to the class for the next thirty days.

https://gist.github.com/3539316

by andrew on August 30, 2012 at 8:42 pm. #

Are there any examples of this being done in Flex or ActionScript? I have mounted the wsdl using data services in Flex which has generated the classes for the ClassesService but Im not clear on how to pass the credentials with the getClasses call. This call requires an argument of type GetClassesRequest. Where do I go from here?

Please help

by Max on September 7, 2012 at 2:11 pm. #

Hey Max I don’t know Flex or ActionScript myself but maybe this document will help you figure out how to pass parameters to the GetClasses method

http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_3.html

Also, you can find more about the GetClassesRequest in the MINDBODY docs here

http://api.mindbodyonline.com/Doc

Click to expand the Class Service and then click on GetClasses

Hope this helps! ๐Ÿ™‚

by Devin on September 7, 2012 at 4:16 pm. #

Just starting this whole MBO API thing and your guide and resources have been extremely helpful! Thanks a lot!

by Vincent Kardos on September 13, 2012 at 10:13 pm. #

Just started using MindBody API and your guide has been very useful. Great tutorial. Thanks a lot.

by Diya on September 20, 2012 at 3:50 pm. #

Thanks devin .. great article

by lily on November 2, 2012 at 12:06 pm. #

Great tutorial !
Thanks Devin !!!!!!!!

by pro2060 on November 13, 2012 at 10:51 am. #

Great tutorial. Thanks for the help. I am receiving the following error when I run the first script above:

[code]
Fatal error: Class ‘SoapClient’ not found in /hermes/waloraweb019/b71/moo.studiosevacom/MINDBODY_API_v0.5.php on line 13
[/code]

Am i do declare the SoapClient class before this call?

[code]
$this->client = new SoapClient(‘https://api.mindbodyonline.com/0_5/ClassService.asmx?WSDL’, array(“soap_version”=>SOAP_1_1, ‘trace’=>true));
[/code]

by David McCarran on February 3, 2013 at 12:53 am. #

do a php_info() and check that you have PHP 5 or higher with the SOAP extension installed. http://www.php.net/manual/en/book.soap.php

by Devin on February 3, 2013 at 9:51 am. #

I have checked this and spoke with my server’s support (fatcow.com). I am using SOAP through PEAR. I was told by them to include the statement

require_once(‘SOAP/Client.php’);
or
require_once(‘SOAP/Server.php’);

inside the script.

I added each of these to the script you provided, without luck. Any suggestions?

by David McCarran on February 4, 2013 at 1:36 am. #

and PHP 5.2 as well.

by David McCarran on February 4, 2013 at 1:37 am. #

Could this be the problem?

PEAR packages available on FatCow’s platform

PACKAGE VERSION STATE
SOAP 0.9.1 beta

by David McCarran on February 4, 2013 at 1:56 am. #

Sorry to blow up the comments. I spoke with my hosting company and was advised that since I am using PEAR SOAP that I must adjust SoapClient call to ‘Soap_Client’ with the underscore. Useful information to know.

by David McCarran on February 5, 2013 at 8:24 am. #

David, I use Fatcow too. I’m trying to get SOAP running and I’ve had to hunt around a lot for info. Can you tell me what your final solution was?

I went into my php.ini and created a require_once call then directed it to โ€˜/usr/local/php/pear/Soap_Client.phpโ€™
Something about that isn’t right – my site is having a fit.

Thanks in advance!!

by Mische on April 16, 2013 at 8:56 pm. #

Yes I was able to get the API to work through Pear SOAP on Fatcow. If you still need assistance check this out:
http://stackoverflow.com/questions/15657138/pear-soap-xml-request?noredirect=1#comment25017989_15657138.

I used the PEAR SOAP generateProxyCode() method to create all the methods used by WSDL. I then called these methods with arguments given at the https://api.mindbodyonline.com/Doc site. Good luck!

by David McCarran on November 24, 2013 at 11:05 pm. #

I get this error after setting up like you said. Do you know what it means?

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl’ : failed to load external entity “https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl”

by Robbie on March 2, 2013 at 7:09 pm. #

I solved it. I changed https: to http:

by Robbie on March 5, 2013 at 5:13 am. #

I found this very helpful. Just waiting for the owner to open my activation link. I was wondering if you could personally recommend a XML to JSON plugin. The UI frameworks these days all take in JSON.

by Winston on March 9, 2013 at 8:09 pm. #

Sorry I don’t know of any XML to JSON plugins I use PHP’s json_encode() method to convert an array to JSON http://php.net/manual/en/function.json-encode.php

by Devin on March 19, 2013 at 4:25 am. #

Mindbody doesn’t support JSON. You can review it on their API support forum.

by Carlos on March 19, 2013 at 3:47 am. #

How can i get something like this:

Monday, June 10

name of class
name of class
name of class

Tuesday, June 11

name of class
name of class
name of class

etc.

any ideas?

by Jamie on June 13, 2013 at 10:42 am. #

very useful. thank you. I may combine with some of the wordpress plugin code found here: https://github.com/ParkourVisions/wp-pkv-mindbody

by Mike iLL on September 4, 2013 at 5:04 pm. #

Thank you so much for this!

My integration had stopped working, reporting the following error:
ERROR: [HTTP] Error Fetching http body, No Content-Length, connection closed or chunked data

Was able to fix by adding the following line of code:
$this->client->__setLocation(“https://api.mindbodyonline.com/0_5/ClassService.asmx”);
below this one:
$this->client = new SoapClient(‘https://api.mindbodyonline.com/0_5/ClassService.asmx?WSDL’, array(“soap_version”=>SOAP_1_1, ‘trace’=>true));

The new SoapClient call can also be replaced with:
$this->client = new SoapClient(“https://api.mindbodyonline.com/0_5/ClassService.asmx?WSDL”,
array(
‘trace’ => 1,
‘stream_context’ => stream_context_create(array(‘http’ => array(‘protocol_version’ => 1.0) ) )
)
);

which may avoid other problems (not sure what).

by Mike iLL on October 1, 2013 at 4:39 pm. #

Thanks Mike, I had the same problem and your solution worked.

by Yuga on May 2, 2014 at 9:45 am. #

[…] biographies directly from the MBO database. The API widget owes most of it’s development to this Devin Crossman coding […]

by URU Yoga – custom MINDBODY API | Media Zoo on October 1, 2013 at 4:49 pm. #

How can you specify the type for an XML element? For example, CheckoutShoppingCart requires you to specify the Item type as either ‘Service’, ‘Product’, etc.

by Dimitry on October 8, 2013 at 10:14 pm. #

You can add the attribute by adding a SoapVar to your Request array like this:

$request = $mb->checkoutShoppingCart(array(
‘Test’=>’true’,
‘ClientID’=>1234,
‘CartItems’=>array(
‘CartItem’=>array(
‘Quantity’=>1,
‘Item’ => new SoapVar(array(‘ID’=>”1234″), SOAP_ENC_ARRAY, ‘Service’, ‘http://clients.mindbodyonline.com/api/0_5’),
‘DiscountAmount’ => 1234
)
),
‘Payments’ => array(
‘PaymentInfo’ => new SoapVar(array(‘Amount’=>”1234″), SOAP_ENC_ARRAY, ‘CompInfo’, ‘http://clients.mindbodyonline.com/api/0_5’)
)
));

hope that works for you!

by Devin on October 9, 2013 at 12:13 am. #

Thanks for the help! That worked. No quotes around the ID value though, but that’s ok!

by Dimitry on October 9, 2013 at 3:46 pm. #

Thanks for sharing! I’m dabbling with the MBO API to potentially add some customization for a local studio. This saved me a lot of time.

by Brad C on October 20, 2013 at 1:57 pm. #

Thanks.

by Jason Armour on November 3, 2013 at 3:49 am. #

Please help! I keep getting this error and I have the right credentials…

<

InvalidCredentials
102
Permission denied.
Full
0
0
0

My request is:

#######
#######

####

owner
######

####

>

by Savion on January 8, 2014 at 10:07 pm. #

It’s not letting me post the xml… but I get the 102 error. Please help

by Savion on January 8, 2014 at 10:08 pm. #

Don’t mean to spam this forum but I found my solution. You must use the activation code in Mindbody first before you can do anything.

My question now is what is the best way to create a user login form? Thanks!

by Savion on January 9, 2014 at 12:09 am. #

Hello ,
How to fetch today’s class which startdatetime is 15-01-2014T11:00Am and Enddatetime is 10-01-2014T11:30Am,
I am also passing the ClassID,ClassDescriptionID it always give me today’s total class.Please help me

by Anand P on January 15, 2014 at 8:01 am. #

Can I submit info via the API? We created a free trial form that we hope to pass data directly into the MB database. Right now we’re using an iframe but there’s no way to know when someone clicks submit button and this way we’d be able to track the submissions and still have the customer prospect info in the MB system.

by Mike on February 21, 2014 at 10:38 pm. #

Extremely Useful, thanks a lot…!!

by Vikas on March 25, 2014 at 11:09 am. #

How can I get more parameters for classes I want to add the description and the room from my classes?

by tiemen on April 2, 2014 at 10:44 am. #

[…] is a segment of Devin Crossman’s great tutorial that got me started on the MindBody API. This is the section that explains how you have to create […]

by Creating your Mindbody Credentials | Media Zoo on April 18, 2014 at 7:49 pm. #

I’m looking for a way to integrate Mindbody with another newsletter service other them constant contact like mail chimp or mail jet. Do you have any suggestion of who could help me?

by Alex on July 5, 2014 at 9:29 pm. #

Nice tutorial! Have you setup a way to process payments?

by Steven on July 29, 2014 at 5:35 pm. #

Hi Steven, the Sale Service has a CheckoutShoppingCart method. You can call it similar to the following example

$checkoutShoppingCartRequest = $mb->CheckoutShoppingCart(array(
'Test'=>'true',
'ClientID'=>1234,
'CartItems'=>array(
'CartItem'=>array(
'Quantity'=>1,
'Item' => new SoapVar(
array('ID'=>'1357'),
SOAP_ENC_ARRAY,
'Service',
'http://clients.mindbodyonline.com/api/0_5'
),
'DiscountAmount' => 0
)
),
'Payments' => array(
'PaymentInfo' => new SoapVar(
array(
'CreditCardNumber'=>'4111111111111111',
'ExpYear'=>'2015',
'ExpMonth'=>'06',
'Amount'=>'130',
'BillingAddress'=>'123 Happy Ln',
'BillingPostalCode'=>'93405'
),
SOAP_ENC_ARRAY,
'CreditCardInfo',
'http://clients.mindbodyonline.com/api/0_5'
)
)
));

But note according to https://developers.mindbodyonline.com/Resources/FAQs

The MINDBODY API has the ability to process credit cards, however this requires that the studio specified within the API request has an active merchant account with MINDBODY. TransFirst, Bluefin, and EZDebit are the only API-supported merchant processors at this time, meaning that access is currently limited to clients within the United States, Canada, Australia, and the UK.

If you are not using one of those payment processors you could integrate the payment processing with another api and continue the checkout in Mindbody using a custom payment method. Then change your PaymentInfo section of the request to include the custom payment method ID that you set up in Mindbody

$checkoutShoppingCartRequest = $mb->CheckoutShoppingCart(array(
'Test'=>'true',
'ClientID'=>1234,
'CartItems'=>array(
'CartItem'=>array(
'Quantity'=>1,
'Item' => new SoapVar(
array('ID'=>'1357'),
SOAP_ENC_ARRAY,
'Service',
'http://clients.mindbodyonline.com/api/0_5'
),
'DiscountAmount' => 0
)
),
'Payments' => array(
'PaymentInfo' => new SoapVar(
array(
'Amount'=>'130',
'ID'=>'5',
),
SOAP_ENC_ARRAY,
'CreditCardInfo',
'http://clients.mindbodyonline.com/api/0_5'
)
)
));

by Devin on July 30, 2014 at 4:07 am. #

Hello Devin,

Could you please an example to include ClassIDs into CheckoutShoppingCart parameter for payment process.

by Mamun on August 16, 2015 at 3:46 pm. #

is there a way to call for Client Member Status?

by Kayne Morrison on October 7, 2014 at 12:15 pm. #

awesomeee tutorial by the way ๐Ÿ™‚

by Kayne Morrison on October 7, 2014 at 12:16 pm. #

๐Ÿ™‚ Thanks Kayne, it’s a bit out of date now but I’m glad people are still finding it useful.. There is a function called GetActiveClientMemberships on the ClientService that requires a ClientID parameter and an optional LocationID. I think that will give you the information you are looking for.

by Devin on October 7, 2014 at 1:35 pm. #

Is it possible to access the prices for classes via the API? I have been looking over the docs and can’t seem to find anything.

by Doug on October 14, 2014 at 8:04 pm. #

Hi Doug, you can find which services will pay for a class and their associated price with the GetServices method. If you’re using my api wrapper you can do something like $services = $mb->GetServices(array('ClassID'=>19328,'LocationID'=>1,'HideRelatedPrograms'=>true)); which gives all the services that can pay for the class with ClassID 19328. Hope this helps ๐Ÿ™‚

by Devin on October 14, 2014 at 9:10 pm. #

Thanks Devin,

That pointed me in the right direction, I appreciate it!

by Doug on October 24, 2014 at 9:50 pm. #

Hi, I’m trying to limit GetClasses by StaffID. It doesn’t seem to be working. Is there an example available? I am successfully filtering classes by date using your original wrapper. Thanks, Randall

by Randall on October 29, 2014 at 9:23 pm. #

Hi Randall what response are you getting? It works for me when I try $classes = $mb->GetClasses(array("StaffIDs"=>array("123456"))); where 123456 is the ID of the staff member.

by Devin on October 30, 2014 at 3:36 pm. #

Yes, that worked. Simple mistake on my part… and now further problems. I’ll post in a new thread. Your API wrapper is wonderful by the way. Thanks!

by Randall on October 31, 2014 at 1:47 am. #

Hello, I’m attempting to list all clients currently signed up for a class.

$classes = $mb->GetClassVisits(array(“ClassIDs”=>array(“2805”)));

Should I be using the Client Service? I’ve tried various forms of the above including using many different requests and services. Any help is much appreciated.

by Randall on October 31, 2014 at 2:13 am. #

It should be $classVisits = $mb->GetClassVisits(array('ClassID'=>2805)); You can only look up one class at a time with this method. If you want to be more efficient you’ll have to get a copy of your database from Mindbody and figure out the right SQL then send it to them to convert into a stored procedure you can access with the FunctionData method of the DataService.. man they sure make it complicated.

by Devin on October 31, 2014 at 3:41 pm. #

Thanks so much Devin it worked for me. Your tutorial was very clear and it saved me hours of frustration.

by chisco on January 8, 2015 at 8:44 am. #

I’m working in MINDBODY API, and just keep getting this error, even in the sandbox:

[Message] => Staff credentials must be supplied with a SiteID

Any clues on exactly how to fix that? It should be fine in the sandbox, I would think!

by Mark on March 7, 2015 at 6:37 am. #

Hi Mark, are you passing in the SiteIDs as an array? Your User Credentials should look something similar to

array('UserCredentials'=>array('Username'=>'****','Password'=>'****', "SiteIDs"=>array('-99')))

by Devin on March 7, 2015 at 7:02 am. #

Wondering if anyone could point me in the right direction for an API issue. I am trying to use the GetBookableItems call to get a list of available appointments that can be booked. It looks like the call requires “SessionTypeIDs.” Is there a call I can use to get the “SessionTypeIDs”? I am haven’t been able to find where I can get these. Any help appreciated, thanks!

by Doug on April 20, 2015 at 4:15 pm. #

Hi Doug. You can get the SessionTypeIDs from the GetSessionTypes method of the SiteService. I just tried but had no luck getting anything useful returned from the GetBookableItems call.. Might have to contact Mindbody about that.. Hope you have better luck!

by Devin on April 23, 2015 at 3:56 am. #

Just released a new MindBodyWP plugin that supports shortcodes. It’s fully customisable and the plugin is open source. Let me know if you like it, need changes on it etc.

by Brad on May 8, 2015 at 2:57 am. #

Hello Brad,

I will be greatfull to you if you help me about MindBody Api.

by Mamun on August 17, 2015 at 9:55 am. #

Hi Devin,

I’m looking into being able to make multiple calls to the API with different SiteIDs, but when I try to create more than one instance of the MB_API class, php reports that the functions are not found via the second instance. Tried sub-classing and even duplicating the class same thing. What am I missing, man?

by Mike iLL on May 28, 2015 at 11:46 pm. #

Gotten as far as seeing that the protected apiMethods array is empty upon a second instance of the MB_API class.

by Mike iLL on May 29, 2015 at 1:59 am. #

That’s strange. I don’t have the same problem using this code

$mb = new MB_API(array(
    "SourceName"=>'ABCD', 
    "Password"=>'EFGH', 
    "SiteIDs"=>array('1234')
));
$result1 = $mb1->ApiMethod();

$mb2 = new MB_API(array(
    "SourceName"=>'IJKL', 
    "Password"=>'MNOP', 
    "SiteIDs"=>array('5678')
));
$result2 = $mb2->ApiMethod();

by Devin on May 29, 2015 at 3:50 am. #

Found a workaround ’cause I don’t actually need to make the requests together. Just updating the class attribute for SiteID.

by Mike iLL on May 29, 2015 at 5:06 pm. #

Hey Guys! I am not a coder and am looking for a freelance coder to integrate the Mindbody API to my wordpress site. I’d like to be able to track when a user of my site has gone to the gym or a yoga session and know the location and type of class taken by that individual. The other information includes the name & email (they will need their email associated with Mindbody in order to access my site). Can you guys give me an idea of how long that would take to implement, test & launch?

Would really appreciate your input!

by Paolo on June 1, 2015 at 11:41 pm. #

I am trying to become familiar with the MINDBODY Api and the documentation is not very in-depth. This is the best tutorial I have seen so far. Thank you for this.

Right now I am trying to send the request to using the Sandbox credentials and I keep getting back an error message in the XML saying ‘Invalid sourcename or password’

Does the request not work for the sandbox/demo account they provide?

by Max on June 21, 2015 at 12:05 am. #

Hi Max. I’m glad you found this post helpful! The request does work for the sandbox. You should be using SiteID -99 and your developer sourcename and password for the source credentials not the sandbox login username and password.

by Devin on June 21, 2015 at 11:23 am. #

Devin, When I try to use your $checkoutShoppingCartRequest within PEAR SOAP running on PHP5.3 I am getting these errors:

Notice: Undefined property: stdClass::$PaymentInfo in /hermes/waloraweb019/b71/moo.studiosevacom/saleOYC.php on line 35

Fatal error: Class ‘SoapVar’ not found in /hermes/waloraweb019/b71/moo.studiosevacom/saleOYC.php on line 35

Is there any other way to get the xsi:type=”Service” in the request?

I can make API Calls that dont contain the xsi:type in them.

by David McCarran on July 21, 2015 at 8:47 pm. #

Please let me know
How can i include ClassIDs as parameter in CheckoutShoppingCart?

by Mamun on August 16, 2015 at 7:22 pm. #

Hi Everyone,

We are trying to integrate the MB API but are having zero luck and the support at MB is rubbish.

I am looking for someone who has fully integrated this into a fitness website. Happy to pay someone to work with my guys to do it or pay someone to integrate it.

Devin do you offer this service?

Would appreciate any help!!

Jonathan

by Jonathan Fernandes on August 18, 2015 at 3:07 pm. #

Trying to add 2 “PaymentInfo”‘s for split payments but only the 2nd one is getting added to the array. I assume it is because the elements have the same key, but can’t seem to find a fancy work around that will work with the API. Any thoughts?

‘Payments’ => array(
‘PaymentInfo’ => new SoapVar(
array(
‘LastFour’=>$_POST[‘stored_cc’],
‘Amount’=>$credit_total,
),
SOAP_ENC_ARRAY,
‘StoredCardInfo’,
‘http://clients.mindbodyonline.com/api/0_5’
),
‘PaymentInfo’ => new SoapVar(
array(
‘Amount’=>$balance_total,
),
SOAP_ENC_ARRAY,
‘DebitAccountInfo’,
‘http://clients.mindbodyonline.com/api/0_5’
)
),

by Doug Vander Meulen on October 5, 2015 at 3:41 pm. #

Hi, When I am trying to integrate CheckoutShoppingCart API from sendbox mindbodyonle , then i am getting error that is below .
“Card Authorization Failed DECLINED:1000410001:Invalid merchant:”
My SAOP Request :

Array
(
[SourceCredentials] => Array
(
[SourceName] => ‘test’
[Password] =>………….
[SiteIDs] => Array
(
[0] => -99
)

)

[UserCredentials] => Array
(
[Username] => Siteowner
[Password] => apitest1234
[SiteIDs] => Array
(
[0] => -99
)

)

[ClientID] => 1234
[cartID] => 1
[InStore] => 1
[SendEmail] => 1
[CartItems] => Array
(
[CartItem] => Array
(
[Quantity] => 1
[Item] => SoapVar Object
(
[enc_type] => 300
[enc_value] => Array
(
[ID] => 1357
)

[enc_stype] => Service
[enc_ns] => http://clients.mindbodyonline.com/api/0_5
)

[DiscountAmount] => 0
)

)

[Payments] => Array
(
[PaymentInfo] => SoapVar Object
(
[enc_type] => 300
[enc_value] => Array
(
[CreditCardNumber] => 4111111111111111
[ExpYear] => 2016
[ExpMonth] => 06
[Amount] => 130

)

[enc_stype] => CreditCardInfo
[enc_ns] => http://clients.mindbodyonline.com/api/0_5
)

)

)

by Niraj Kumar on October 31, 2015 at 10:25 am. #

This is response.
stdClass Object
(
[CheckoutShoppingCartResult] => stdClass Object
(
[Status] => InvalidParameters
[ErrorCode] => 9999
[Message] => Card Authorization Failed DECLINED:1000410001:Invalid merchant:

[XMLDetail] => Full
[ResultCount] => 0
[CurrentPageIndex] => 0
[TotalPageCount] => 0
)

)

by Niraj Kumar on October 31, 2015 at 10:28 am. #

How to get location name from location id?

by Prasad on February 1, 2016 at 7:25 am. #

Devin; Impressive work. Follow up.

by Dave Crowley on July 22, 2016 at 11:51 am. #

Thank you so much for putting this together. Your tutorial fills in a lot of the glaring omissions in the official MBO docs.

by Pete Doherty on July 22, 2016 at 8:55 pm. #

What is the difference between ‘$sourceCredentials’ and ‘$userCredentials’ in MINDBODY_API_v0.5.php?

by Subhadip on August 23, 2016 at 6:04 am. #

Source credentials are your developer API credentials and user credentials are for staff member credentials that you need to include with some API calls

by Devin on August 23, 2016 at 6:24 am. #

Thank You.

by Subhadip on August 23, 2016 at 8:24 am. #

Hello Devin,

I am trying to run your code in this blog but I am always getting the error as follows:

InvalidCredentials101Invalid sourcename or password.

Can you please help ASAP.

Thanks!

by Saud on October 13, 2016 at 7:02 am. #

API as of yesterday has doubled in price. Now is $10/month.

by Mark Turnerhill on October 18, 2016 at 4:24 pm. #

I have been trying to get account balances through the API using the following code and your MB_API.php

$data = $mb->GetClientAccountBalances(array(‘ClientIDs’=>$client));

Where $client is assigned the client id in the system I have also tried using the Unique id 100000x that is assigned by mindbody. I have also tried multiple clients.

This is what i get in response with both types of ID as strings.

array (size=1)
‘GetClientAccountBalancesResult’ =>
array (size=7)
‘Status’ => string ‘Success’ (length=7)
‘ErrorCode’ => int 200
‘XMLDetail’ => string ‘Full’ (length=4)
‘ResultCount’ => int 0
‘CurrentPageIndex’ => int 0
‘TotalPageCount’ => int 0
‘Clients’ =>
array (size=0)
empty

Any help would be appreciated.

Thanks,
J

by Jason Bradshaw on April 13, 2017 at 7:11 pm. #

J, Try this

โ€˜ClientIDsโ€™ => ($client)

by Matt on April 21, 2018 at 2:57 am. #