GithubHelp home page GithubHelp logo

carnevalle / cartodbclient-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vizzuality/cartodbclient-php

0.0 1.0 0.0 163 KB

A CartoDB client for PHP

Home Page: http://developers.cartodb.com

License: BSD 4-Clause "Original" or "Old" License

PHP 100.00%

cartodbclient-php's Introduction

Introduction

This is a very simple PHP library to make use of the CartoDB API as easy as possible. It does not cover the whole API, just the authentication bit (using OAuth) and running SQL queries. If you want to learn more about the CartoDB API check out the documentation

The library is presented as a single file with very few dependencies to make it as easy as possible to use it.

Requirements

Example use

You'll need to get an API key and secret from http://cartodb.com

Then is pretty simple

<?php
require_once 'cartodb.class.php';

$config = array();

$config['key'] = 'key';
$config['secret'] = 'secret';
$config['email'] = '[email protected]';
$config['password'] = 'password';
$config['subdomain'] = 'subdomain';

# Create the client using the API key and Secret.
$cartodb =  new CartoDBClient($config);

# Check if the key and secret work fine and you are authorized
if(!$cartodb->authorized) {
    echo("There is a problem authenticating, check the key and secret");
    die();
}

# Now we can perform queries straigh away. The second param indicates if you want
# the result to be json_decode (true) or just return the raw json string

$result = $cartodb->runSql("SELECT *,geojson(the_geom) FROM my_table",false);
echo($result);

?>

We are working still on the docs, but basically you can run any SQL supported by PostgreSQL and PostGIS. You can also concatenate the queries with ";" to insert multiple records in one shot for example.

Changelog

  • 2014/02/06 : createTable() signature modified (no longer supports sending schema, just table name). Improved documentation of insertRow() method and token tmp storage to allow multi-account testing.
  • 2014/02/05 : Deprecated getTables() and dropTable(), no longer present in the API endpoints. Added getTableVisualizations() and dropTableVisualization() to provide same functionality (although slower and performing more queries).

cartodbclient-php's People

Contributors

jatorre avatar kartones avatar carnevalle avatar javisantana avatar jherencia avatar tokumine avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.