PHP thanks.io example

Here is an example of sending a postcard through our API. For the full api please visit www.thanks.io/api.

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.thanks.io/api/v2/send/postcard",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"image_template\": 6,\n    \"handwriting_style\": 4,\n    \"message\": \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\",\n    \"recipients\": [\n        {\n            \"name\": \"Current Resident\",\n            \"address\": \"123 Main Street\",\n            \"city\": \"Fake City\",\n            \"province\": \"NY\",\n            \"postal_code\": \"55555\",\n            \"country\": \"US\"\n        }\n    ]\n}",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json",
    "Authorization: Bearer [YOUR TOKEN]",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
curl_close($curl);
echo $response;

?>
Did this answer your question?