2017 © Pedro Peláez
 

library airtable-php

Manipulate Airtable API using PHP

image

armetiz/airtable-php

Manipulate Airtable API using PHP

  • Monday, July 16, 2018
  • by armetiz
  • Repository
  • 3 Watchers
  • 7 Stars
  • 1,849 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Airtable for PHP

Basic SDK to deal with airtable records., (*1)

Installation

Tell composer to require this bundle by running:, (*2)

``` bash composer require armetiz/airtable-php, (*3)


## Usage ```php $key = "APP_KEY"; // Generated from : https://airtable.com/account $base = "BASE_ID"; // Find it on : https://airtable.com/api $table = "TABLE_NAME"; // Find it on : https://airtable.com/api $airtable = new Airtable($key, $base); $records = $airtable->findRecords($table);

Available methods, (*4)

  • Airtable::createTableManipulator(string $table): TableManipulator
  • Airtable::getRecord(string $table, string $id)
  • Airtable::createRecord(string $table, array $fields)
  • Airtable::setRecord(string $table, array $criteria = [], array $fields)
  • Airtable::updateRecord(string $table, array $criteria = [], array $fields)
  • Airtable::containsRecord(string $table, array $criteria = [])
  • Airtable::flushRecords(string $table)
  • Airtable::deleteRecord(string $table, array $criteria = [])
  • Airtable::findRecord(string $table, array $criteria = [])
  • Airtable::findRecords(string $table, array $criteria = [])

Example

Simple member indexer that encapsulate Airtable within simple API. Can be used to start a CRM on Airtable., (*5)

Note: Because Airtable doesn't allow schema manipulation using their public API, you should configure table using the WebUI with the following, (*6)

  • Id : text
  • Firstname : text
  • Lastname : text
  • Email : email
  • CreatedAt : Date and time
  • Picture : Attachments
$key   = "APP_KEY"; // Generated from : https://airtable.com/account
$base  = "BASE_ID"; // Find it on : https://airtable.com/api
$table = "TABLE_NAME"; // Find it on : https://airtable.com/api

$airtable = new Airtable($key, $base);

$records = $airtable->findRecords($table);
use Armetiz\AirtableSDK\Airtable as AirtableClient;

class MemberIndex
{
    private $airtable;

    public function __construct(AirtableClient $airtableClient, string $table)
    {
        $this->airtable = $airtableClient->createTableManipulator($table);
    }

    public function clear()
    {
        $this->airtable->flushRecords();
    }

    public function save(array $data)
    {
        $criteria = ["Id" => $data["id"]];
        $fields   = [
            "Id"                    => $data["id"],
            "Firstname"             => $data["firstName"],
            "Lastname"              => $data["lastName"],
            "Email"                 => $data["email"],
            "CreatedAt"             => (string)$data["createdAt"],
        ];

        if ($this->airtable->containsRecord($criteria)) {
            $this->airtable->updateRecord($criteria, $fields);
        } else {
            $this->airtable->createRecord($fields);
        }
    }

    public function delete($id)
    {
        $this->airtable->deleteRecord(["Id" => $id]);
    }
}

Testing

Not implemented yet., (*7)

License

This library is under the MIT license. See the complete license., (*8)

Credits

Author - Thomas Tourlourat, (*9)

The Versions

16/07 2018

dev-master

9999999-dev https://github.com/armetiz/airtable-php

Manipulate Airtable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable

25/07 2016

0.3.1

0.3.1.0 https://github.com/armetiz/airtable-php

Manipulate Airtable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable

25/07 2016

0.3.0

0.3.0.0 https://github.com/armetiz/airtable-php

Manipulate Airtable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable

20/06 2016

0.2.0

0.2.0.0 https://github.com/armetiz/airtable-php

Manipulate Airtable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable

17/06 2016

0.1.3

0.1.3.0 https://github.com/armetiz/airtable-php

Manipulate AirTable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable

17/06 2016

0.1.2

0.1.2.0 https://github.com/armetiz/airtable-php

Manipulate AirTable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable

17/06 2016

0.1.1

0.1.1.0 https://github.com/armetiz/airtable-php

Manipulate AirTable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable

17/06 2016

0.1.0

0.1.0.0 https://github.com/armetiz/airtable-php

Manipulate AirTable API using PHP

  Sources   Download

MIT

The Requires

 

php sdk airtable