The PHP Ringside API Client operates in a similar manner to the Facebook API client, however, there are some extra features in the Ringside API Client.
- Will handling routing of API requests to appropriate social server
- Will provide ability to have immediate access to information about global user across networks
- Provides ability to know which flavor you are being rendered as
- Supports Ringside API
- Packaged in a namespace type structure.
- Configuration mechanism built in.
The big difference between the Ringside Client and the facebook PHP client comes in configuration. Facebook client is hardcoded for facebook.com, which is great for facebook but does not make it a ubiquitous client. That said we provide the similar structure but opened up to point to mulitple servers with routing support. Configuration for the client can be done
- with configuration files and overriding the config notation inside client
- by passing parameters into constructor of client
There are three parameters to configure for a Ringside Server
- The WEB url (RingsideApiClientsConfig::$webUrl)
This url is the root url to the WEB tier of the social network. For example http://localhost/ringside or http://www.facebook.com.
- The Restserver url ( RingsideApiClientsConfig::$serverUrl ). This is the rest end point for API calls. For example http://localhost/ringside/restserver.php or http://api.facebook.com/restesrver.php.
- The Trust endpoint ( RingsideApiClientsConfig::$socialUrl ). This is the location of a trust endpoint used for third party connections to create a trust relationship with an API server.
Creating a Ringside API client should be done as such, this approach uses a configuration file.
/*
* Includes
* Notice the package structure and naming.
*/
include_once('ringside/api/clients/RingsideApiClientsConfig.php');
require_once( 'ringside/api/clients/RingsideApiClients.php');
/*
* Setting up Configuration. Notice the parameters all look similar
* and in a local setup they would be. But as you scale up and migrate
* components to different servers each layer can be configured separately.
* note: $hostport gets the local server and is only useful in a configuration
* where everything runs on the same box.
*/
$hostport = $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'];
RingsideApiClientsConfig::$serverUrl = "http:;
RingsideApiClientsConfig::$webUrl = ""http:;
RingsideApiClientsConfig::$socialUrl = ""http:;
/*
* Private and Public Key
* The client will need these to create a connection.
*/
$private = "230987229h8923fh83ryfah9813";
$public = "2938u9r28h89283389d9192eu128";
/*
* Create the client can be done where ever needed.
*/
$client = new RingsideApiClients( $public , $private );
/*
* now client can be used throughout to make calls back to the social server.
*/
An alternate with no configuration files or config setup would be to pass this information in via the constructors.
The constructor for RingsideApiClients is the following
public function __construct($api_key, $secret, $webUrl = null, $serverUrl = null, $socialUrl = null, $client = null ) {
$api_key - the api key for the current application
$secret - private key for the current application
$webUrl - This url is the root url to the WEB tier of the social network.
$serverUrl - This is the rest end point for API calls.
$socialUrl - This is the location of a trust endpoint used for third party connections.
$client - A rest client to substitute instead of the current rest cllient, this is primarily used in the special case of sending photos. The goal of this is to allow other protocols to be plugged in for distribution.
/*
* Includes
* Notice the package structure and naming.
*/
require_once( 'ringside/api/clients/RingsideApiClients.php');
/*
* Private and Public Key
* The client will need these to create a connection.
*/
$private = "230987229h8923fh83ryfah9813";
$public = "2938u9r28h89283389d9192eu128";
/*
* Create the client can be done where ever needed.
*/
$client = new RingsideApiClients( $public , $private, "..", "..", ".." );
/*
* now client can be used throughout to make calls back to the social server.
*/