PHP code example of pcbowers / php-airtable

1. Go to this page and download the library: Download pcbowers/php-airtable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pcbowers / php-airtable example snippets






use \pcbowers\Airtable\airtable;
$airtable = new Airtable(array(
    'api_key' => 'api_key',
    'base_id' => 'base_id'
));

echo $airtable->getApiKey() . "<br />";
echo $airtable->getBaseId();

$airtable->listRecords($table_name, array(
    "fields" => array(strings),
    "filterByFormula" => string,
    "maxRecords" => number,
    "pageSize" => number,
    "sort" => array(objects),
    "view" => string,
    "cellFormat" => string,
    "timeZone" => string,
    "userLocale" => string,
    "checkOffset" => true
));

print_r($airtable->listRecords("Users", array(
    "fields" => array("First Name", "Last Name"),
    "sort" => array(array("field" => "First Name", "direction" => "asc")),
    "maxRecords" => 100
)));

$airtable->retrieveRecord($table_name, $record_id);

print_r($airtable->retrieveRecord("Users", "recfauP0XQTTgXMQK"));

$airtable->createRecord($table_name, array(
    "field_name1" => "field_value1",
    "field_name2" => "field_value2"...
));

print_r($airtable->createRecord("Users", array(
    "First Name" => "Joe",
    "Last Name" => "Smith"
)));

$airtable->updateRecord($table_name, $record_id, array(
    "field_name1" => "field_value1",
    "field_name2" => "field_value2"...
), $destructive);

print_r($airtable->updateRecord("Users", "recAkSf8l5IpITPV8", array(
    "First Name" => "Joe1",
    "Last Name" => "Smith1"
)));

$airtable->deleteRecord($table_name, $record_id);

print_r($airtable->deleteRecord("Users", "recU84ywe5m1md4wP"));

print_r($airtable->getLog());
echo "<br />";
print_r($airtable->getLastLog());

composer