Quantcast
Channel: Active questions tagged ampscript - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 359

AMPScript / JS Base64Encode for images create wrong code

$
0
0

I'm trying to create a dynamic QR code to be sent in a triggered mail, but since QR codes are not supported (only bar codes are) am I using Google API to create one. I then try to base64 encode the PNG from Google to put in an img tag (as normally done at websites sometimes).Everything seem to work great except that the base64 encoding returns an invalid string.

<script language=javascript runat=server>  Platform.Load("Core", "1")  var imgFetch = HTTP.Get('http://www.google.com/chart?chs=200x200&chld=M&cht=qr&chl=otpauth:%2F%2Ftotp%2FTest%3Fsecret%3DGVFXGN3WIYZEMYKW');  var imgData = imgFetch.Content;  var imgDataEncoded = Base64Encode(imgData);  Write('<img src="data:image/png;base64,'+ imgDataEncoded +'" />');</script>

I took the raw image data from the Google call and ran it through another base64 encoder and it returns a different (valid) string then the Base64Encode function above. I also tried the same using AMPScript, with the same result.

Am i missing something here?


Viewing all articles
Browse latest Browse all 359

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>