Signed URL
Generate images on demand with credentials stored on your backend
var CryptoJS = require("crypto-js");
const fetch = require("node-fetch");
const signedURL = "https://cdn.dynapik.com/signed/images/60c4d598225837023457d.jpg"; // Replace with your Signed URL in Console
const apiKey = "REPLACE_WITH_YOUR_KEY";
const templateId = signedURL.split('/').pop().split('.').shift();
const values = {
price_1: "$123"
}
const d = Buffer.from(JSON.stringify(values), 'utf8').toString('base64')
const signed = CryptoJS.HmacSHA256(`${templateId}.${d}`,apiKey)
const s = signed.toString(CryptoJS.enc.Base64);
const serveURL = `${signedURL}?s=${s}&d=${d}`;<?php
// template ID
$templateId = "erpy1wwl5j43";
// your API key
$apiKey = '216|zoRs4104XrcxsxgSlh2dDXxaE2CCPS9VlrSe8D6f';
// dynamic fields values
$values = [
'bg_image' => 'https://useflipp.s3.amazonaws.com/templates/shape-pink.png',
'hey' => 'https://useflipp.s3.amazonaws.com/templates/clubhouse.png',
'body' => 'Try changing this text in a playground or via API',
'url' => 'useflipp.com',
];
// encode query
$query = base64_encode(json_encode($values);
// make signature
$signature = hash_hmac('sha256', $templateId . $query, $apiKey);
// get a direct URL to the image
$baseUrl = "https://s.useflipp.com/{$templateId}.png?s={$signature}&v={$query}";
?>Last updated
Was this helpful?
