Skip to content

Instantly share code, notes, and snippets.

@odthomas
Forked from kasrak/create_record.php
Created August 14, 2020 11:24
Show Gist options
  • Save odthomas/563f1aa31ef6881dad6520f08385ecda to your computer and use it in GitHub Desktop.
Save odthomas/563f1aa31ef6881dad6520f08385ecda to your computer and use it in GitHub Desktop.
Create a record in Airtable using PHP
<?php
$data = array(
"fields" => array(
"Name" => "Hello world"
)
);
$data_json = json_encode($data);
$ch = curl_init("https://api.airtable.com/v0/YOUR_BASE_ID/YOUR_TABLE_NAME?api_key=YOUR_API_KEY");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
$result = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment