-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmain-functions.php
52 lines (39 loc) · 1.27 KB
/
main-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?
require 'vendor/autoload.php';
use TANIOS\Airtable\Airtable;
$airtable = new Airtable(array(
'api_key' => 'API_KEY',
'base' => 'BASE_ID',
));
// Get all entries from the table 'Deals' where the 'Status' is 'New'
$params = array(
"filterByFormula" => "AND( Status = 'New' )"
);
$request = $airtable->getContent( 'Deals', $params);
do {
$response = $request->getResponse();
var_dump( $response[ 'records' ] );
}
while( $request = $response->next() );
print_r($request);
// Adding a new contact to the 'Contacts' table
$contact_details = array(
'Name' =>"John Brandon",
'Address' => "1234 Street Name, City, State, Zip, Country",
'Telephone #' => '123-123-1239',
'Email' =>'[email protected]',
);
$new_contact = $airtable->saveContent("Contacts",$contact_details);
// Get the id after the entry is saved
echo 'New Contact ID: '.$new_contact->id;
// Save a new 'Payment' and link it to a 'Contact'
if ($new_contact->id){
$payment_details = array(
'Amount' =>50,
'Contact' => array($new_contact->id), // array of ids to create a relationship
'Type' => array('Purchase'), // single-select of multi-select
'Date'=> date('Y-m-d')
);
$new_payment = $airtable->saveContent("Payments",$payment_details);
echo 'Last Payment ID: '.$new_payment->id;
}