Coldfusion : Odd Output of Timestamp : Replaces with an x

98 Views Asked by At

I think my timestamp needs to be at the end of the string. But when I move it there - I get an odd output of the &times turns into an x. Is there a fix for this? At the front it works fine.

<cfset usem = "timestamp=#unixdatetimeNow.getTime()#&symbol=#pair#&side=#side#&type=#type#&quantity=#size#">

Outputs :

timestamp=1645552579468&symbol=SHIBUSDT&side=sell&type=market&quantity=9005

<cfset usem = "symbol=#pair#&side=#side#&type=#type#&quantity=#size#&timestamp=#unixdatetimeNow.getTime()#">

Outputs with the x :

symbol=SHIBUSDT&side=sell&type=market&quantity=9005×tamp=1645552579468

How do I fix this x replacement? Does it in both cfset and in script

1

There are 1 best solutions below

0
SOS On

Update: 2022-04-06

TLDR; Bottom line, nothing needs to be done. As mentioned in the comments, and your other thread ColdFusion : Binance API : Not all sent parameters were read, the parameter name is still &timestamp, it just appears to be xtamp when displayed on screen.


It's because the substring &times is being treated as the html entity &times, which gets rendered as the symbol x.

Why is [timestamp] fine at the front but not back?

When timestamp is the first parameter in the query string, there's no & preceding "time". So it's not treated as an html entity.

Keep in mind this is just a presentation issue. The substring &time is only rendered as x when you output the variable. The actual contents of the variable don't change. So nothing happens its used in your cfhttp call:

 // sends "&timestamp" not "xstamp"
 cfhttp(....) {
    ...
    cfhttpparam(type="body", value="#yourString#");
 }

Fixed with : &amp; : <cfset usem = "...&amp;timestamp=#unixdatetimeNow.getTime()#">

That might display correctly on screen, but will break your cfhttp call because it sets the parameter name to the literal string &amp;timestamp but the API is expecting a parameter named timestamp.