Skip to content

Commit

Permalink
Fix for TASK-444: API name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
troydavisson committed Apr 16, 2012
1 parent cc87589 commit 70dadf6
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 63 deletions.
14 changes: 7 additions & 7 deletions README.md
@@ -1,21 +1,21 @@
flexmls API - version 2
Spark API - version 2
=====================
A PHP wrapper for the flexmls REST API. This version has enough differences from version 1 that upgrading will
A PHP wrapper for the Spark REST API. This version has enough differences from version 1 that upgrading will
require changes to existing code.


Documentation
-------------
For full information on the API, see http://www.flexmls.com/developers
For full information on the API, see http://sparkplatform.com/docs


Usage Examples
------------------------
// include the flexmlsAPI core which autoloads other classes as necessary
// include the Spark core which autoloads other classes as necessary
require_once("lib/Core.php");

// connect using flexmls API authentication
$api = new flexmlsAPI_APIAuth("api_key_goes_here", "api_secret_goes_here");
// connect using Spark API authentication
$api = new SparkAPI_APIAuth("api_key_goes_here", "api_secret_goes_here");

// identify your application (optional)
$api->SetApplicationName("MyPHPApplication/1.0");
Expand All @@ -40,7 +40,7 @@ Error Codes
<thead>
<tr>
<th>HTTP Code</th>
<th>flexmls API Error Code</th>
<th>Spark API Error Code</th>
<th>Automatic Retry</th>
<th>Description</th>
</tr>
Expand Down
56 changes: 28 additions & 28 deletions examples.php
@@ -1,6 +1,6 @@
<?php

// include the flexmlsAPI core which autoloads other classes as necessary
// include the SparkAPI core which autoloads other classes as necessary
require_once("lib/Core.php");


Expand All @@ -9,15 +9,15 @@
* Changed in version 2.0
*
* The newest version of the PHP API client (version 2.0) allows you to select which authentication method
* you'd like to use against the API. Version 1.0 was limited to the flexmls API authentication method and is
* you'd like to use against the API. Version 1.0 was limited to the Spark API authentication method and is
* now done using:
*
* $api = new flexmlsAPI_APIAuth("api_key_goes_here", "api_secret_goes_here");
* $api = new SparkAPI_APIAuth("api_key_goes_here", "api_secret_goes_here");
*
* With version 2.0, you can now authenticate using OAuth2 support. For more details on OAuth2 with the flexmls API,
* see https://www.flexmls.com/developers/api/api-services/authentication/
* With version 2.0, you can now authenticate using OAuth2 support. For more details on OAuth2 with the Spark API,
* see http://sparkplatform.com/docs/authentication/oauth2_authentication
*
* $api = new flexmlsAPI_OAuth($client_id, $client_secret, $application_uri);
* $api = new SparkAPI_OAuth($client_id, $client_secret, $application_uri);
*
* To issue a Grant request with the "code" value provided by the API:
*
Expand Down Expand Up @@ -45,7 +45,7 @@
*
*/

$api = new flexmlsAPI_APIAuth("api_key_goes_here", "api_secret_goes_here");
$api = new SparkAPI_APIAuth("api_key_goes_here", "api_secret_goes_here");

// identify your application (optional)
$api->SetApplicationName("PHP-API-Code-Examples/1.0");
Expand All @@ -72,26 +72,26 @@
*
* To enable Memcache or Memcached cache support, the host and port (both optional) can be given:
*
* $api->SetCache( new flexmlsAPI_MemcacheCache() ); // defaults to localhost and port 11211
* $api->SetCache( new SparkAPI_MemcacheCache() ); // defaults to localhost and port 11211
* or:
* $api->SetCache( new flexmlsAPI_MemcachedCache('remotehost', 12345) ); // overrides both defaults
* $api->SetCache( new SparkAPI_MemcachedCache('remotehost', 12345) ); // overrides both defaults
*
* depending on the Memcached-compliant driver you choose.
*
*
* To enable WordPress caching, no arguments are required: this method uses the set_transient() and get_transient()
* functions created by WordPress which can be extended by other WP plugins for additional (or modified) functionality.
*
* $api->SetCache( new flexmlsAPI_WordPressCache() );
* $api->SetCache( new SparkAPI_WordPressCache() );
*
*
* To enable database caching via the MySQLi extension, you can either pass connection details to the class:
*
* $api->SetCache( new flexmlsAPI_MySQLiCache($hostname, $database, $username, $password, $table_name));
* $api->SetCache( new SparkAPI_MySQLiCache($hostname, $database, $username, $password, $table_name));
*
* or you can re-use an existing MySQLi connection by passing the object:
*
* $api->SetCache( new flexmlsAPI_MySQLiCache($my_mysqli_object) );
* $api->SetCache( new SparkAPI_MySQLiCache($my_mysqli_object) );
*
* By default, a $table_name of "api_cache" is assumed if none is given. The structure for that table is:
*
Expand All @@ -117,19 +117,19 @@
* request some basic account and system information
*/
$result = $api->GetSystemInfo();
// https://www.flexmls.com/developers/api/api-services/system-info/
// http://sparkplatform.com/docs/api_services/system_info
print_r($result);

$result = $api->GetPropertyTypes();
// https://www.flexmls.com/developers/api/api-services/property-types/
// http://sparkplatform.com/docs/api_services/property_types
print_r($result);

$result = $api->GetStandardFields();
// https://www.flexmls.com/developers/api/api-services/standard-fields/
// http://sparkplatform.com/docs/api_services/standard_fields
print_r($result);

$result = $api->GetMyAccount();
// https://www.flexmls.com/developers/api/api-services/my-account/
// http://sparkplatform.com/docs/api_services/my_account
print_r($result);


Expand All @@ -138,15 +138,15 @@
*/

$result = $api->GetMyListings();
// https://www.flexmls.com/developers/api/api-services/listings/
// http://sparkplatform.com/docs/api_services/listings
print_r($result);

$result = $api->GetOfficeListings();
// https://www.flexmls.com/developers/api/api-services/listings/
// http://sparkplatform.com/docs/api_services/listings
print_r($result);

$result = $api->GetCompanyListings();
// https://www.flexmls.com/developers/api/api-services/listings/
// http://sparkplatform.com/docs/api_services/listings
print_r($result);

/*
Expand All @@ -161,7 +161,7 @@
'_expand' => 'PrimaryPhoto'
)
);
// https://www.flexmls.com/developers/api/api-services/listings/
// http://sparkplatform.com/docs/api_services/listings
print_r($result);

/*
Expand All @@ -171,15 +171,15 @@
$id = "20100912153422758914000000"; // this comes from the Id value in a listing response

$result = $api->GetListingPhotos($id);
// https://www.flexmls.com/developers/api/api-services/listing-photos/
// http://sparkplatform.com/docs/api_services/listings/photos
$result = $api->GetListingDocuments($id);
// https://www.flexmls.com/developers/api/api-services/listing-documents/
// http://sparkplatform.com/docs/api_services/listings/listing_documents
$result = $api->GetListingOpenHouses($id);
// https://www.flexmls.com/developers/api/api-services/open-houses/
// http://sparkplatform.com/docs/api_services/listings/open_houses
$result = $api->GetListingVideos($id);
// https://www.flexmls.com/developers/api/api-services/listing-videos/
// http://sparkplatform.com/docs/api_services/listings/videos
$result = $api->GetListingVirtualTours($id);
// https://www.flexmls.com/developers/api/api-services/virtual-tours/
// http://sparkplatform.com/docs/api_services/listings/virtual_tours


/*
Expand All @@ -189,19 +189,19 @@
$photo_id = "20080917142739989238000000";

$result = $api->GetListingPhoto($id, $photo_id);
// https://www.flexmls.com/developers/api/api-services/listing-photos/
// http://sparkplatform.com/docs/api_services/listings/photos


/*
* contact management
* https://www.flexmls.com/developers/api/api-services/contacts/
* http://sparkplatform.com/docs/api_services/contacts
*/

$result = $api->GetContacts();

$new_contact = array(
"DisplayName" => "Example Contact",
"PrimaryEmail" => "apiexample@flexmls.com",
"PrimaryEmail" => "apiexample@sparkplatform.com",
"PrimaryPhoneNumber" => "888-123-4567",
"HomeStreetAddress" => "123 S. Main St",
"HomeLocality" => "Fargo",
Expand Down
2 changes: 1 addition & 1 deletion lib/APIAuth.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_APIAuth extends flexmlsAPI_Core implements flexmlsAPI_AuthInterface {
class SparkAPI_APIAuth extends SparkAPI_Core implements SparkAPI_AuthInterface {
protected $api_key = null;
protected $api_secret = null;

Expand Down
2 changes: 1 addition & 1 deletion lib/AuthInterface.php
@@ -1,5 +1,5 @@
<?php

interface flexmlsAPI_AuthInterface {
interface SparkAPI_AuthInterface {

}
2 changes: 1 addition & 1 deletion lib/CacheInterface.php
@@ -1,6 +1,6 @@
<?php

interface flexmlsAPI_CacheInterface {
interface SparkAPI_CacheInterface {

function get($key);
function set($key, $value, $expire);
Expand Down
34 changes: 17 additions & 17 deletions lib/Core.php
@@ -1,46 +1,46 @@
<?php

/**
* A PHP wrapper for the flexmls REST API
* A PHP wrapper for the Spark REST API
*
* Version: 2.0
*
* Source URI: https://github.com/flexmls/flexmls_api4p2
* Source URI: https://github.com/sparkapi/sparkapi4p2
* Author: (c) Financial Business Systems, Inc. 2011, 2012
* Author URI: http://flexmls.com/developers
* Author URI: http://sparkplatform.com/docs
*
* This file is part of the flexmls PHP API client..
* This file is part of the Spark PHP API client..
* The flexmls PHP API client is free software: you can redistribute it and/or modify
* The Spark PHP API client is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* The flexmls PHP API client is distributed in the hope that it will be useful,
* The Spark PHP API client is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with the flexmls PHP API client. If not, see <http://www.gnu.org/licenses/>.
* along with the Spark PHP API client. If not, see <http://www.gnu.org/licenses/>.
*/


spl_autoload_register(array('flexmlsAPI_Core', 'autoload'));
spl_autoload_register(array('SparkAPI_Core', 'autoload'));


class flexmlsAPI_Core {
class SparkAPI_Core {
public $api_client_version = '2.0';

public $api_base = "api.flexmls.com";
public $api_base = "api.sparkapi.com";
public $api_version = "v1";

private $debug_mode = false;
private $debug_log = null;
protected $force_https = false;
protected $transport = null;
protected $cache = null;
protected $cache_prefix = "flexmlsAPI_";
protected $cache_prefix = "SparkAPI_";

protected $headers = array();

Expand All @@ -64,18 +64,18 @@ class flexmlsAPI_Core {

function __construct() {
$this->SetHeader("Content-Type", "application/json");
$this->SetHeader('User-Agent', 'flexmls API PHP Client/' . $this->api_client_version);
$this->SetHeader('User-Agent', 'Spark API PHP Client/' . $this->api_client_version);
}

static function autoload($class_name) {
if (preg_match('/^flexmlsAPI/', $class_name)) {
$file_name = preg_replace('/^flexmlsAPI\_/', '', $class_name);
if (preg_match('/^SparkAPI/', $class_name)) {
$file_name = preg_replace('/^SparkAPI\_/', '', $class_name);
include_once(dirname(realpath(__FILE__)) . '/' . $file_name . '.php');
}
}

function SetApplicationName($name) {
$this->SetHeader('X-flexmlsApi-User-Agent', str_replace(array("\r", "\r\n", "\n"), '', trim($name)));
$this->SetHeader('X-SparkApi-User-Agent', str_replace(array("\r", "\r\n", "\n"), '', trim($name)));
}

function SetDebugMode($mode = false) {
Expand All @@ -84,7 +84,7 @@ function SetDebugMode($mode = false) {

function SetDeveloperMode($enable = false) {
if ($enable) {
$this->api_base = "api.developers.flexmls.com";
$this->api_base = "api.developers.sparkapi.com";
return true;
}
else {
Expand Down Expand Up @@ -220,7 +220,7 @@ function return_first_result($response) {
function MakeAPICall($method, $service, $cache_time = 0, $params = array(), $post_data = null, $a_retry = false) {

if ($this->transport == null) {
$this->SetTransport(new flexmlsAPI_CurlTransport);
$this->SetTransport(new SparkAPI_CurlTransport);
}

// parse format like "5m" into 300 seconds
Expand Down
2 changes: 1 addition & 1 deletion lib/CoreTransport.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_CoreTransport {
class SparkAPI_CoreTransport {


function __construct() {
Expand Down
2 changes: 1 addition & 1 deletion lib/CurlTransport.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_CurlTransport extends flexmlsAPI_CoreTransport implements flexmlsAPI_TransportInterface {
class SparkAPI_CurlTransport extends SparkAPI_CoreTransport implements SparkAPI_TransportInterface {
protected $ch = null;

function __construct() {
Expand Down
2 changes: 1 addition & 1 deletion lib/MemcacheCache.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_MemcacheCache implements flexmlsAPI_CacheInterface {
class SparkAPI_MemcacheCache implements SparkAPI_CacheInterface {
protected $cache = null;

protected $host = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/MemcachedCache.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_MemcachedCache implements flexmlsAPI_CacheInterface {
class SparkAPI_MemcachedCache implements SparkAPI_CacheInterface {
protected $cache = null;

protected $host = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/MySQLiCache.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_MySQLiCache implements flexmlsAPI_CacheInterface {
class SparkAPI_MySQLiCache implements SparkAPI_CacheInterface {
protected $cache = null;

protected $hostname = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/OAuth.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_OAuth extends flexmlsAPI_Core implements flexmlsAPI_AuthInterface {
class SparkAPI_OAuth extends SparkAPI_Core implements SparkAPI_AuthInterface {
protected $force_https = true;
protected $api_client_id = null;
protected $api_client_secret = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/TransportInterface.php
@@ -1,6 +1,6 @@
<?php

interface flexmlsAPI_TransportInterface {
interface SparkAPI_TransportInterface {

function make_request($req = array());

Expand Down
2 changes: 1 addition & 1 deletion lib/WordPressCache.php
@@ -1,6 +1,6 @@
<?php

class flexmlsAPI_WordPressCache implements flexmlsAPI_CacheInterface {
class SparkAPI_WordPressCache implements SparkAPI_CacheInterface {


function get($key) {
Expand Down

0 comments on commit 70dadf6

Please sign in to comment.