1. Go to this page and download the library: Download sleiman/airtable-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/ */
sleiman / airtable-php example snippets
use \TANIOS\Airtable\Airtable;
$airtable = new Airtable(array(
'api_key' => 'API_KEY',
'base' => 'BASE_ID'
));
// You don't have to use all the params, they are added as a reference
$params = array(
"filterByFormula" => "AND( Status = 'New' )",
"sort" => array(array('field' => 'Count', 'direction' => "desc")),
"maxRecords" => 175,
"pageSize" => 50,
"view" => "Name of your View"
);
$request = $airtable->getContent( 'Contacts', $params);
do {
$response = $request->getResponse();
var_dump( $response[ 'records' ] );
}
while( $request = $response->next() );
print_r($request);
// Create an array with all the fields you want
$new_contact_details = array(
'Name' =>"Contact Name",
'Address' => "1234 Street Name, City, State, Zip, Country",
'Telephone #' => '123-532-1239',
'Email' =>'[email protected]',
);
// Save to Airtable
$new_contact = $airtable->saveContent( "Contacts", $new_contact_details );
// The ID of the new entry
echo $new_contact->id;
print_r($new_contact);
$check = $airtable->quickCheck("Contacts",$field,$value);
$check = $airtable->quickCheck("Contacts","Email","[email protected]");
if($check->count > 0){
// the value is already there
var_dump($check->records);
} else {
// it's not there
}