PHP code example of davidzadrazil / airtable-api-php

1. Go to this page and download the library: Download davidzadrazil/airtable-api-php 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/ */

    

davidzadrazil / airtable-api-php example snippets


$airtable = new DavidZadrazil\AirtableApi\Airtable('API_KEY', 'BASE_ID');
$request = new DavidZadrazil\AirtableApi\Request($airtable, 'TABLE_NAME');

$tableRequest = $request->getTable();
do {
  foreach ($tableRequest->getRecords() as $record) {
    echo $record->getName();
    echo $record->getEmail();
    echo $record->getAnotherValue();
  }
} while ($tableRequest = $tableRequest->nextPage());

$request->getTable(['pageSize' => 50, 'filterByFormula' => '{Name} = "test"']);

$response = $request->createRecord(
  [
    'Name' => 'This appears in Name field',
    'Email' => '[email protected]',
    'LinkToAnotherTable' => ['recsH5WYbYpwWMlvb']
  ]
);

$response->isSuccess(); // true / false
$response->getRecords(); // returns newly created record with ID


$response = $request->updateRecord('recsH5WYbYpwWMlvb', ['Name' => 'Updated value']);
$response->isSuccess(); // true / false

$response = $request->deleteRecord('recsH5WYbYpwWMlvb');
$response->isSuccess(); // true / false