Last active
June 15, 2021 14:20
-
-
Save kasrak/394b471a4dbccf4d43021eca76e065fe to your computer and use it in GitHub Desktop.
Create a record in Airtable using PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
I have tested the above code and it is working well.