Example Code
At the moment our example code is very sparse, but we do hope the api is simple enough for that to not be too much of a problem.
The API in the real world
The ScubaTribe API is used to power the ScubaTribe facebook App, which shows a clients reviews on a tab inside their
account
Take a look at the Facebook app
as used by Dive-careers.com
We are also aware of at least one dive shop management suite which is currently integrating ScubaTribe and of a couple of CMS plugins in the works.
Simple PHP examples
Request the clients feedback summary
<?php
//build query
$url = 'https://api.scubatribe.com/v1/';
$url .= 'reviews/summary';
$apiKey = 'MYSCUBATRIBEAPIKEY';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//set the http verb
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
//Set some http headers
$httpHeader = array('Accept: application/json',
'API-KEY: ' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
//make the request with curl
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
//decode the JSON into an array
$result = json_decode($result, true);
Sample Response:
{ "results": { "numReviews": 44, "rating": 4.39, "recommend": 98, "distribution": { "5": { "count": 23, "percent": 52 }, "4": { "count": 16, "percent": 36 }, "3": { "count": 4, "percent": 9 }, "2": { "count": 1, "percent": 2 }, "1": { "count": 0, "percent": 0 } } }, "num_records": 4, "status": "OK" }
Post a reply to a review on behalf of a client
<?php
//Over simplified text source
$text = $_POST['text'];
$review_id = $_POST['review_id'];
//build query
$url = 'https://api.scubatribe.com/v1/';
$url .= 'reviews/'.$review_id.'/comment';
$apiKey = 'MYSCUBATRIBEAPIKEY';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Add the fields to POST
$post_fields =array('text'=> $text);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_fields));
//set the http verb
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
//Set some http headers
$httpHeader = array('Accept: application/json',
'API-KEY: ' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
//make the request with curl
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
//decode the JSON into an array
$result = json_decode($result, true);
Sample JSON Response:
{ "message": "Comment Added", "new_comment_count": 3, "status": "OK" }