Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A convenient PHP library for working with Kasabi

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 LICENCE
Octocat-spinner-32 README.md
Octocat-spinner-32 potassium.php
README.md

potassium

A convenient PHP library for working with Kasabi

Overview

This is a very early stage library for working with Kasabi APIs. When I say early stage, I mean I've only used it once (for my English Heritage demo).

The design philosophy of Potassium is to make things simple and get out of the way quickly. Potassium will default to sensible values, guess common patterns, simplify overcomplex formats and try to return PHP native types whenever possible. At the same time it allows you to tweak its behaviour and get access to the full response from Kasabi so you can diagnose problems or program with the raw formats if you need to.

Potassium has no dependencies but does require PHP's cURL module.

Examples

Create a new instance

$kasabi = new Potassium($api_key);

Perform a SPARQL select:

$results = $kasabi->get('http://api.kasabi.com/api/sparql-endpoint-foo', array('query'=>'select ?name ?age where {...'));

SPARQL select results are automatically simplified into a nested array:

[ {'name' => 'Rod', 'age' => 25}, {'name' => 'Jane', 'age' => 23}, {'name' => 'Freddy', 'age' => 30} ]

Follow the happy path:

$results = $kasabi->get('sparql-endpoint-foo', array('query'=>$query));
if ($results) {
  // do something amazing...
}
else {
  $response = $kasabi->last_response();
  print "Failed with response: " . $response->responseCode;
  print "Body: " . $response->body;
  print "Headers: \n";
  print_r($response->headers);
}

Changes

2012-01-25: removed option to use short names for APIs, you now need to specify the full URI

Licence

This work is hereby released into the Public Domain.

To view a copy of the public domain dedication, visit http://creativecommons.org/licenses/publicdomain or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Something went wrong with that request. Please try again.