Created
February 17, 2020 14:52
-
-
Save wallawe/891366b1ad4e2cbfed164ea3ad579afe to your computer and use it in GitHub Desktop.
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
$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