Skip to content

Instantly share code, notes, and snippets.

@wallawe
Created February 17, 2020 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallawe/891366b1ad4e2cbfed164ea3ad579afe to your computer and use it in GitHub Desktop.
Save wallawe/891366b1ad4e2cbfed164ea3ad579afe to your computer and use it in GitHub Desktop.
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append('{
"message": "Hey {firstName},\\nIt was great meeting you last week at the party. We'd love to have you back at the next one!\\n\\nBest,\\n-Jackie",
"handwriting": <STRING - handwriting id>,
"card": <STRING - stationery id>,
"recipients": [
{
"firstName": "Ze",
"lastName": "Dude",
"company": "Unemployed",
"street1": "25 Main Street",
"city": "Los Angeles",
"state": "CA",
"zip": "90210"
}
],
"from": {
"firstName": "Jackie",
"lastName": "Treehorn",
"street1": "1 Random Street",
"street2": "Apt 33A",
"city": "Malibu",
"state": "CA",
"zip": "90263"
}
}');
$request->setRequestUrl('https://api.handwrite.io/v1/send');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'content-type' => 'application/json',
'authorization' => '<your secret key>'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment