This article provides an introduction to the Buying Buddy SDK for PHP and guides you through the basic setup process.
What is the Buying Buddy SDK for PHP?
The Buying Buddy SDK for PHP works in conjunction with the Buying Buddy JavaScript plugin to provide additional SEO capabilities for your website. It enables server-side pre-rendering of content, making your listings and property pages indexable by search engines.
Key Benefits:
- Indexable Listings: Display widgets output HTML with links that search engines can follow
- SEO-Friendly URLs: Property details pages use clean URLs without query parameters
- Optimized Meta Data: Automatically generates title tags and meta descriptions with property addresses
- Server-Side Rendering: Content is available before JavaScript loads, improving SEO
Important Notes
Optional Tool: The SDK is purely optional. It's only required if you want to extend the Buying Buddy JavaScript plugin with SEO benefits.
WordPress Not Supported: The SDK is not supported for WordPress websites. Use the Buying Buddy WordPress Plugin instead.
Data Usage Restriction: You cannot use the SDK to run queries and get data for your own custom designs. This violates MLS IDX rules as data license agreements do not permit this use.
Requirements
Before implementing the SDK, ensure you have:
Technical Requirements
- PHP Environment: Your website must run on PHP
- cURL Enabled: Must be enabled on your server
- Cache Directory: Create a writable "cache" directory for the SDK
- Latest Buying Buddy Plugin: Use the current JavaScript plugin version
From Your Buying Buddy Account
- API Key: Your Buying Buddy API Key for Programming APIs
- Location: My Account > Account Settings > Preferences
- Account Activation Key: Your website activation key
- Location: Website & Widgets > Getting Started (see bottom of page)
Prerequisites
- Complete basic Buying Buddy installation first
- Follow the detailed installation instructions for your website type at: Widgets > Installation and Setup in your Buying Buddy account
- Refer to our Installing Buying Buddy guide for general setup
Getting Started
Step 1: Download the SDK
- Go to Widgets > Installation and Setup in your Buying Buddy account
- Select your website from the dropdown
- If your website is set as a PHP environment (e.g., raw PHP, Joomla), scroll down to find the SDK download link
- Download the SDK ZIP file
The ZIP file contains:
MBB
folder withMyBuyingBuddy.php
SDK filescache
directory for temporary files
Step 2: Upload and Setup
- Extract the ZIP file contents
- Upload the
MBB
folder to your website's root directory - Ensure the
cache
directory has write permissions
Step 3: Modify Your JavaScript Plugin
Critical Change Required: You must modify the seo
setting in your Buying Buddy JavaScript plugin.
Change from:
var MBB = { seo : "false", data:{ acid : "[ACTIVATION_KEY]" } };
To:
var MBB = { seo : "true", data:{ acid : "[ACTIVATION_KEY]" } };
Important: Setting seo : "true"
causes widget HTML to be injected as code rather than loaded with JavaScript. Once you make this change, you must use the SDK for every widget on your site.
Step 4: Include SDK in Your Pages
Add this PHP code to the top of each page where you use Buying Buddy widgets:
<?php require 'mbb/MyBuyingBuddy.php'; // Enter your API Key and Account Activation Key $mbbObj = new MyBuyingBuddy( array( "api_key" => "[YOUR_API_KEY]", "acid" => "[ACTIVATION_KEY]" ) ); ?>
Step 5: Update Widget Implementation
When using the SDK, you must modify how widgets are implemented:
For each widget, add:
- PHP
$widgetParams
array - HTML div that includes PHP object to load content
- Always include a filter in the div for display widgets
Example - Featured List Widget:
<?php // Widget parameters $widgetParams = array( "filter" => "mls_id:ca64+city:DENVER", "limit" => 20, "order" => "create_dt desc", "page" => 1 ); $listObj = $mbbObj->getWidget("MBBv3_FeaturedList", $widgetParams); ?>
<div id="MBBv3_FeaturedList" filter="mls_id:ca64+city:DENVER"> <?php echo $listObj->html?> </div>
Next Steps
Once you have the basic SDK setup complete:
- Implement SEO Features: See our SEO Implementation Guide for detailed SEO setup
- Add Specific Widgets: Reference our Widget Implementation Guide for all widget types
- Configure URLs: Set up SEO-friendly URLs and .htaccess rules