Category Archives: Application Programming Interface (API)

Functions & Template Variables


NOTE: This is Historical Information About the Now Inoperative ShiftCode API – Reproduced Just for Saving the Info for the Future

The API product allows you to easily build your own custom applications on your own server.

You can download the latest PHP classes here:  api-1.1.0.zip
The file includes a demonstration game of Heads or Tails!

Functions

Name Function Multiple Support
Jackpot – Add Entries JackpotAdd no
Paid to Signup – Load Ad PtsLoad no
Shoutbox – Post ShoutboxPost no
User – Balances UserBalances no
User – Load UserLoad no
User – Login UserLogin no
User – Register UserRegister no
User – Cash Transaction UserTransCash YES
User – Points Transaction UserTransPoints YES

Additional Options

Template Variables

If you wish to include stats from your own server, you can include them in your template by creating an XML file on your server formatted like the one below.

<?xml version="1.0"?>
<template>
	<stat1>234</stat1>
	<stat2>865.23</stat2>
</template>

You can pass a user’s id to your XML file like so:
http://example.com/template.php?uid={~$user.id~}

The stats can be displayed in your template by using the following code:

Stat 1: {~$api->template('stat1')~}
Stat 2: {~$api->template('stat2')~}


API:Multiple Support

If a template function has multiple supports it means more than one request can be sent to it.

Usage

Take for example we wanted to credit the user $0.20 and $0.40 as separate transactions.

Example Code

$sc->userTransCash(array(
	array(
		'trans_user' => 1,
		'trans_amt' => .20,
		'trans_type' => 'credit',
		'trans_name' => 'Winner',
	),
	array(
		'trans_user' => 1,
		'trans_amt' => .40,
		'trans_type' => 'credit',
		'trans_name' => 'Winner',
	),
));
 

API:JackpotAdd

From ShiftCode
 
Request Variables
Variable Example Value Required Description
jackpot_id 1 Yes The jackpot the entries are being added to. (1-5)
jackpot_amt 1.00 Yes The amount being added to the jackpot.
jackpot_entries 2 Yes The number of entries being given to the user.
jackpot_uid 1 Yes The unique identifier of the user getting the entries.

Response Variables

Variable Example Value Description
success 1 The entries were successful added.

Example Code

$sc->jackpotAdd(array(
	'jackpot_id' => 1,
	'jackpot_amt' => 1.2,
	'jackpot_entries' => 2,
	'jackpot_uid' => 1,
));

API:PtsLoad

Request Variables
Variable Example Value Required Description
pts_id 1 Yes The unique identifier of the offer being loaded

Response Variables

Variable Example Value Description
pts_id 1 The offer’s unique identifier
pts_name Great Deals The name of the offer.
pts_siteURL http://shiftcode.com The URL of the offer.
pts_bannerURL http://shiftcode.com/images/banner.gif The URL of the banner for the offer.
pts_code   HTML Code to display the banner and site URL.
pts_requirements   The requirements of the offer.
pts_cash 1.00 The cash amount given to a member for the offer.
pts_cid 1 The category the offer is in
pts_cashAdv 2.00 The cash amount the advertiser pays for the offer.
pts_cashback 10 The percent of a sale given to a member for completing the offer.
pts_points 1 The points amount given to a member for the offer. (→ Points System product required)
pts_jackpot   If the field is not blank then the user gets jackpot entries. (→ Paid to Signup Jackpot product required)
pts_min 0 Minimum number of offers a member must have completed before attempting this offer.
pts_redoWait 0 Number of days before a user can attempt this offer again.
pts_redoFolder 0 The redo wait is factored based on the pending (0) folder and the completed (1) folder.
success 1 The offer was successful loaded.

Example Code

$response = $sc->ptsLoad(array(
	'pts_id' => 1,
));
echo $response->pts_name;

API:ShoutboxPost

Request Variables
Variable Example Value Required Description
shout_name John Yes The name of the user posting.
shout_msg Hi everyone Yes The message being posted.
shout_uid 0 No The user ID of the user posting. (→ Membership product required)
shout_ip 1.1.1.1 No The IP address of the user posting.

Response Variables

Variable Example Value Description
success 1 The message successful posted

Example Code

$sc->shoutboxPost(array(
	'shout_name' => 'Admin',
	'shout_msg' => 'Hello everyone, I am using the API.',
	'shout_uid' => 1,
));

API:UserBalances

Request Variables
Variable Example Value Required Description
user_ids 1,2 Yes The unique identifier of the user(s)

Response Variables

Variable Example Value Description
balances
{
  "1" : {
    "id": 1,
    "balance": 0.5,
    "points": 0.5
  },
  "2" : {
    "id": 2,
    "balance": 0.5,
    "points": 0.5
  }
}
An object which contains each user and their balances.
success 1 The user was successful loaded.

Example Code

$response = $sc->userBalances(array(
	'user_ids' => '1,2,3',
));

// User with the ID of 1
echo $response->balances->{'1'}->balance;
echo $response->balances->{'1'}->points;

// User with the ID of 2
echo $response->balances->{'2'}->balance;
echo $response->balances->{'2'}->points;

API:UserLoad

Request Variables
Variable Example Value Required Description
user_id 1 Yes The unique identifier of the user being loaded

Response Variables

Variable Example Value Description
user_id 1 The user’s unique identifier
user_first John The user’s first name
user_last Smith The user’s last name
user_username johnsmith The user’s username
user_email johnsmith@gmail.com The user’s e-mail address
user_cash 1.00 The user’s current cash balance.
user_cashTotal 1.00 The user’s lifetime cash balance.
user_points 1.00 The user’s current points balance. (→ Points System product required)
user_pointsTotal 1.00 The user’s lifetime points balance. (→ Points System product required)
user_dateRegistered 2010-07-11 11:52:32 The date of when the user registered.
user_dateActive 2011-01-05 13:02:33 The date of when the user was last active.
user_ip 1.1.1.1 The user’s current IP address.
user_geoCountry United States The user’s country based on their IP address.
user_geoRegion New York The user’s state, province or region based on their IP address.
user_geoISP RCN Corporation The user’s Internet Service Provider based on their IP address.
user_page /members/index.php The last page the user was seen on.
user_upgradeID 1 The unique identifier of the upgrade this user is assigned to. (→ Upgrade product required)
user_upgradeName Basic The name of the upgrade this user is assigned to. (→ Upgrade product required)
user_status Member The user’s current status.
user_verified 0 The user’s verification level.
success 1 The user was successful loaded.

Example Code

$response = $sc->userLoad(array(
	'user_id' => 1,
));
echo $response->user_username;

API:UserLogin

Request Variables
Variable Example Value Required Description
cookie username|passwordhash Yes A dump of the user’s cookies containing their login token, the name of the cookie is SC_member
server_ip 1.1.1.1 Yes The user’s IP address
server_agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 Yes The user’s browser agent
server_language en-us No The user’s browser language
page /headsortails/index.php No The page the user is currently on

Response Variables

Variable Example Value Description
user_id 1 The user’s unique identifier
user_first John The user’s first name
user_last Smith The user’s last name
user_username johnsmith The user’s username
user_email johnsmith@gmail.com The user’s e-mail address
user_cash 1.00 The user’s current cash balance.
user_cashTotal 1.00 The user’s lifetime cash balance.
user_points 1.00 The user’s current points balance. (→ Points System product required)
user_pointsTotal 1.00 The user’s lifetime points balance. (→ Points System product required)
user_dateRegistered 2010-07-11 11:52:32 The date of when the user registered.
user_dateActive 2011-01-05 13:02:33 The date of when the user was last active.
user_ip 1.1.1.1 The user’s current IP address.
user_geoCountry United States The user’s country based on their IP address.
user_geoRegion New York The user’s state, province or region based on their IP address.
user_geoISP RCN Corporation The user’s Internet Service Provider based on their IP address.
user_page /members/index.php The last page the user was seen on.
user_upgradeID 1 The unique identifier of the upgrade this user is assigned to. (→ Upgrade product required)
user_upgradeName Basic The name of the upgrade this user is assigned to. (→ Upgrade product required)
user_status Member The user’s current status.
user_verified 0 The user’s verification level.
user_loggedIn 1 If the user is logged in (1) or not logged in (0).
success 1 The registration was successful

Example Code

$user = $sc->isLoggedIn();

API:UserRegister

Request Variables
Variable Example Value Required Description
user_first John Yes The user’s first name
user_last Smith Yes The user’s last name
user_username johnsmith Yes The user’s username
user_password johnsmith123 Yes The user’s password
user_email johnsmith@gmail.com Yes The user’s e-mail address
user_ip 1.1.1.1 Yes The user’s IP address
user_referrer 0 No The referrer’s ID number
user_refURL http://google.com No The URL from where this user came from.
user_balance 0.00 No The balance to start the member off with.

Response Variables

Variable Example Value Description
success 1 The registration was successful

Example Code

$sc->userRegister(array(
	'user_first' => 'John',
	'user_last' => 'Smith',
	'user_username' => 'johnsmith',
	'user_password' => 'johnsmith123',
	'user_email' => 'johnsmith@gmail.com',
	'user_ip' => '1.1.1.1',
));

API:UserTransCash

Request Variables
Variable Example Value Required Description
trans_username johnsmith Yes The username of whom the transaction is for.
trans_type credit Yes Can be either credit or debit.
trans_amt 0.01 Yes The amount of the transaction.
trans_name Adjustment Yes The name of the transaction that will appear in the user’s history.

Response Variables

Variable Example Value Description
success 1 The transaction was successful

Example Code

$response = $sc->userTransCash(array(
	'trans_user' => 1,
	'trans_type' => 'debit',
	'trans_amt' => 0.01,
	'trans_name' => 'Adjustment',
));
if(isset($response->success))
{
	echo 'Successful Transaction';
}

This function has Multiple Support.


API:UserTransPoints

Request Variables
Variable Example Value Required Description
trans_username johnsmith Yes The username of whom the transaction is for.
trans_type credit Yes Can be either credit or debit.
trans_amt 0.01 Yes The amount of the transaction.
trans_name Adjustment Yes The name of the transaction that will appear in the user’s history.
trans_preventnegative 0 No If set to 1 and the type is a debit then this will prevent the transaction if it concludes with the user having a negative balance.

Response Variables

Variable Example Value Description
success 1 The transaction was successful

Example Code

$response = $sc->userTransPoints(array(
	'trans_user' => 1,
	'trans_type' => 'debit',
	'trans_amt' => 0.01,
	'trans_name' => 'Adjustment',
));
if(isset($response->success))
{
	echo 'Successful Transaction';
}

This function has Multiple Support.


You can view and copy the source of this page: