Skip to content

Instantly share code, notes, and snippets.

@mscoutermarsh
Created September 3, 2018 18:40
Show Gist options
  • Save mscoutermarsh/b6e4c6aeee50817e5ef681d4874addc7 to your computer and use it in GitHub Desktop.
Save mscoutermarsh/b6e4c6aeee50817e5ef681d4874addc7 to your computer and use it in GitHub Desktop.
php convert html/css to image
<?php
require 'vendor/autoload.php';
$html = "<div class='ping'>Pong ✅</div>";
$css = ".ping { padding: 20px; font-family: 'sans-serif'; }";
// Retrieve user_id/api_key from https://htmlcsstoimage.com/dashboard
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://hcti.io/v1/image', [
'auth' => ['user_id', 'api_key'],
'form_params' => ['html' => $html, 'css' => $css]
]);
echo $res->getBody();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment