Configuring phpBay Pro to work in Drupal
NEW phpBay Pro API version 3.0!! Now there's no need to manipulate the API code for it to work in your Drupal site! All you need to do is follow these easy steps:
1. Buy the phpBay Pro API.
2. Unzip files and make changes in config.php according to the API features you want to enable.
3. Upload files into root directory of your site.
4. Add .htaccess lines provided in the API .htaccess file to your Drupal site's .htaccess file ABOVE the clean url lines you already have active.
5. Insert the following code and update for the specific auctions you want to add
<?php
require_once("phpbay/ebay.php");
phpBayAPI("apple tv", 15, "171", "");
?>
That's it!! However, if you're still using the older version of the API, you can follow along with the tutorial below.
+++++ Note the following DRUPAL tutorial is out of date due to the release of version 3.0 of the API. Only follow the below steps if you are using a version older than 3.0 +++++
So you want to use phpBay Pro in your Drupal site?
I've pulled together some simple instructions on how to configure the phpBay Pro API to work within the Drupal php parser.
Unfortunately, some of the programming in the API trips up the Drupal php parser, and it won't work correctly inside Drupal without these modifications. However, phpBay Pro works fine w/o any of these modifications if you use either the Wordpress Plugin or plan on using it on your php web site. Do not make these changes unless using Drupal!
On this page, I'll walk you through the steps of configuring the phpBay Pro API for Drupal. I'll discuss displaying phpBay Pro driven live eBay auctions in Drupal in a later article.
Before you start:
1. Purchased phpBay Pro API from Wired Studios (wiredstudios.com)
2. Setup an affiliate account with eBay from either Commission Junction or Mediaplex
Note: integration of phpBay Pro includes the following files from phpBay Pro: ebay.php, auction.php, template.ebay.results.html. There are other files that come included with phpBay Pro, but these are the files we will use for our integration into Drupal.
Step 1: Create a folder for phpBay Pro in your website.
Using an ftp program, or another program you might use to manage your webspace and website folders, create a folder called "ebay" in your website's root directory. The location of this folder should be similar to www.mysite.com\ebay. You can call this folder something else, but you'll need to update code changes later in this document as such.
Step 2: Update the settings in the ebay.php file provided in phpBay Pro.
In the section above the "No further editing required" section, make the appropriate adjustments to the settings. These adjustments include inserting your website url, as well as adding information regarding your eBay affiliate account.
Step 3: Modify additional settings in the ebay.php file.
This is where the majority of the changes to phpBay Pro take place to allow for Drupal integration. All of the following code changes take place in the "No further editing required" section. I have listed the changes in the order you will arrive at them while scrolling down the page from top to bottom:
[Step 3a]
change: var $redirect_url = "auction.php?eb="
to: var $redirect_url = "ebay/auction.php?eb="
[Step 3b]
change: var $eb_template = "template.ebay.results.html";
to: var $eb_template = "ebay/template.ebay.results.html";
[Step 3c]
Replace this code:
# assign variables
$this->eb_saaff = $aff_type;
if ($this->eb_saaff == "afcj") {
$this->eb_afcj = trim($ebay_pid);
} else {
$this->eb_afmp = trim($ebay_pid);
}
With this code:
#assign variables
$this->ebay_pid = "12345678";
Note: insert your appropriate Commission Junction or Mediaplex PID here.
[Step 3d]
Remove the following code:
# some error trapping before we query ebay
if ($this->eb_saaff == "") {echo "Set the affiliate type variable in ebay.php"; exit;}
if (($this->eb_afcj == "") && ($this->eb_afmp == "")) {echo "Set the affiliate id variable in ebay.php"; exit;}
error_reporting(0);
[Step 3e]
Replace this code:
if ($this->eb_saaff == "afcj") {
$url .= "afcj=" . $this->eb_afcj . "&";
} else {
$url .= "afmp=" . $this->eb_afmp . "&";
}
With this code:
$url .= "afcj=" . $this->ebay_pid . "&";
NOTE, if using Multiplex affiliate account, "afcj" above should be changed to "afmp"
Step 4: Make the following change to the template.ebay.results.hml page:
Find %%image_url%% and replace with %%link_url%%%
Step 5: Upload the following files to your \ebay folder: ebay.php; auction.php; template.ebay.results.html.
You are now ready to begin using phpBay Pro in Drupal!
Next, I'll walk you through displaying your first set of live eBay auctions in your Drupal website!

