fbpx
  1. Home
  2. Knowledge Base
  3. Developer Tools
  4. API
  5. Getting Started with the MemberMouse API

Getting Started with the MemberMouse API

API URL & Credentials

The first thing you need in order to use the MemberMouse API is the API URL and credentials. In the MemberMouse menu go to Developer Tools and click on the API Credentials tab. On this page, you can see your API URL and create and manage API credentials.

Executing an API Call

In order to make an API call you'll need to make a request to the API call URL and pass the appropriate input parameters. The API call URL and input parameters will vary based on the API call being made. See this article for a list of the API calls in MemberMouse and click on an API call to view the associated URL and input parameters.

Download sample code for PHP

Below is a sample API call to create a new member using the createMember API call.

First, we're setting the input parameters as a string of name/value pairs separated by an & and stored in the $inputParams variable.

Next, we're setting the API call URL and initializing a cURL instance.

Finally, we're executing the cURL instance, decoding the result of the call and storing it in a $data variable and then outputting it to the screen.

$inputParams = "apikey={Your_API_Key}&apisecret={Your_API_Secret}&"; 
$inputParams .= "first_name=Tom&"; 
$inputParams .= "last_name=Smith&";
$inputParams .= "[email protected]&"; 
$inputParams .= "phone=(212) 555-7864&"; 
$inputParams .= "membership_level_id=2&";

$apiCallUrl = "https://{Your_API_URL}?q=/createMember";
$ch = curl_init($apiCallUrl); 

curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $inputParams); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$result = curl_exec($ch); 
curl_close($ch);

echo "RAW Response: ".$result."<br />"; 
$data = json_decode($result); 
echo "<pre>";
var_dump($data->response_data); 
echo "</pre>"; 

To modify this for different API calls you'll need to change the API call URL and input parameters according to the documentation for the API call you're making.

mod_security Blocking Requests

On some servers you may find that API calls are being rejected by the server. This is usually related to security settings on the server such as mod_security. To get around this you could trying passing additional headers to the cURL request to simulate it coming from a real browser as follows:

$headers = array(
'Referrer: http://yourdomain.com',
'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0'
);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers); 

Of course you would want to replace http://yourdomain.com with your actual domain.

Accessing the Response Code

In the sample request above the json_decode() method is used to parse the result object from the API call and store it in the $data variable. At this point, the response code can be accessed like this:

$data->response_code;

See this article for a list of the API calls in MemberMouse and click on an API call to view associated response codes.

Accessing Response Data

In the sample request above the json_decode() method is used to parse the result object from the API call and store it in the $data variable. At this point, the response data can be accessed like this:

$data->response_data->username;
$data->response_data->password;
$data->response_data->email;

Where usernamepassword and email are valid parameters in the response data object. The list of valid parameters will vary based on the API call made. See this article for a list of the API calls in MemberMouse and click on an API call to view associated response data.

Download sample code for Python

Was this article helpful?

Related Articles

Can’t find the answer you’re looking for?

Reach out to our Customer Success Team
Contact us!