Some notes for getting started with the MindBody API.
Read this:
http://support.mindbodyonline.com/entries/21301433-how-to-issue-api-credentials
Follow the partner program link on that page and sign up. These pages are often down; it’s not you.
Their docs:
http://api.mindbodyonline.com/Doc
Download the MBO’s API expamples.
https://github.com/mindbody/API-Examples
These examples have some errors. Some includes reference files with the names in the wrong case – they must be working on Windows. Calls to php time functions now require a timezone.
There is no example of using the SiteService or GetActivationCode request that you need to start with the API.
Here is my getActivationCode.php
<?php
require_once("../includes/siteService.php");
if (!isset($_POST['submit'])) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Get Activation Code Demo</title>
<link rel="stylesheet" type="text/css" href="../styles/site.css" />
</head>
<body>
<form method="post" action="getActivationCode.php">
Source Name:
<input type="text" size="25" name="sName"/><br/>
Password:
<input type="password" size="25" name="password"/><br/>
SiteID:
<input type="text" size="5" name="siteID" value="-99"/><br/>
<input type="submit" value="submit" name="submit"/>
</form>
<?php
} else {
$sourcename = $_POST["sName"];
$password = $_POST["password"];
$siteID = $_POST["siteID"];
// initialize default credentials
$creds = new SourceCredentials($sourcename, $password, array($siteID));
$siteService = new MBSiteService(true); //false for no debug!
$siteService->SetDefaultCredentials($creds);
$result = $siteService->GetActivationCode();
/* $cdsHtml = '<table><tr><td>ID</td><td>Name</td></tr>';
$cds = toArray($result->GetClassDescriptionsResult->ClassDescriptions->ClassDescription);
foreach ($cds as $cd) {
$cdsHtml .= sprintf('<tr><td>%d</td><td>%s</td></tr>', $cd->ID, $cd->Name);
}
$cdsHtml .= '</table>';
echo($cdsHtml); */
}
Here is ../includes/siteService.php mbApi.php is provided in the mindbody sample code.
<?php
require_once("mbApi.php");
class MBSiteService extends MBAPIService
{
function __construct($debug = false)
{
$serviceUrl = "http://" . GetApiHostname() . "/0_5/SiteService.asmx?wsdl";
$this->debug = $debug;
$option = array();
if ($debug)
{
$option = array('trace'=>1);
}
$this->client = new soapclient($serviceUrl, $option);
}
/**
* Returns the raw result of the MINDBODY SOAP call.
* @param int $PageSize
* @param int $CurrentPage
* @param string $XMLDetail
* @param string $Fields
* @param SourceCredentials $credentials A source credentials object to use with this call
* @return object The raw result of the SOAP call
*/
public function GetActivationCode(SourceCredentials $credentials = null)
{
$params = $this->GetMindbodyParams($additions=array(), $this->GetCredentials($credentials), $XMLDetaili=null, $PageSize=null, $CurrentPage=null, $Fields=null, $UserCredentials = null);
$result = $this->client->GetActivationCode($params);
if ($this->debug)
{
DebugRequest($this->client);
DebugResponse($this->client, $result);
}
return $result;
}
}