Skip to content

Instantly share code, notes, and snippets.

@kasrak
Last active June 15, 2021 14:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kasrak/394b471a4dbccf4d43021eca76e065fe to your computer and use it in GitHub Desktop.
Save kasrak/394b471a4dbccf4d43021eca76e065fe 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);
@samjco
Copy link

samjco commented Jul 6, 2018

It would be nice to have and error or success response!!!

@odthomas
Copy link

I have tested the above code and it is working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment