simbiotica/cartodbclient-php

CartoDB SQL API v2 client for PHP

1.0.0-beta 2013-04-04 12:58 UTC

This package is not auto-updated.

Last update: 2024-04-13 12:38:06 UTC


README

About

A easy to use PHP client for CartoDB's SQL API v2, using OAuth or API key authentication.

Installation

There are two versions of the library: OAuth or API Key. When installing, you have to choose which to use.

This library requires composer, a package manager for PHP. To use the OAuth version, add the following to your composer.json:

{
    "require": {
        "simbiotica/cartodbclient-php": "dev-master"
    }
}

Or, if you prefer the API key version, use the following:

{
    "require": {
        "simbiotica/cartodbclient-php": "dev-api-key"
    }
}

After, install it using the command:

$ php composer.phar update simbiotica/cartodbclient-php

This will install not only this library, but the required dependencies.

Usage - OAuth

Currently two types of connections are supported: PrivateConnection and PublicConnection. Public connections are a subset of Private ones, as they can be established to any public table, with reduced privileges and configuration requirements

Additionally, TokenStorageInterface implementation is required to presist the OAuth Token across requests. We provide SessionStorage and FileStorage, but feel free to implement your own.

For reference, check the Connection class, where you'll find all the handy functions you'll need. There's also a runSql() function for everything that's not covered by existing functions.

All reponses are wrapped as a Payload object, which holds the formated answer, request metadata and a couple of utilities to handle the result.

No actual demo is provided, but you can view a sort-of-example inside the /tests folder. Remember to fill in your data before trying it.

Usage - API Key

Usage with just API key is less secure, but equaly functional and easier to setup.

All connections are supported by the Connection class, which accepts your domain and, optionally, you API key. If you don't provide it, you will have limited access to the tables.

For reference, check the Connection class, where you'll find all the handy functions you'll need. There's also a runSql() function for everything that's not covered by existing functions.

All reponses are wrapped as a Payload object, which holds the formated answer, request metadata and a couple of utilities to handle the result.

No actual demo is provided, but you can view a sort-of-example inside the /tests folder. Remember to fill in your data before trying it.