2

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

rrk
  • 15,677
  • 4
  • 29
  • 45
Merle_the_Pearl
  • 1,391
  • 3
  • 18
  • 25
  • 2
    Weird. Seems like a bug with the parameter name `timestamp`, or it may just be a reserved word. Change the name to anything else, like "**&R**timestamp" and it works fine. – SOS Feb 22 '22 at 18:16
  • 5
    Oh wait, **&time**stamp is being treated as the html entity `&times`, that's why it's displaying "x". – SOS Feb 22 '22 at 18:39
  • Try wrapping `#unixdatetimeNow.getTime()#` into `#EncodeForURL(unixdatetimeNow.getTime())#` – James A Mohler Feb 22 '22 at 19:48
  • No luck James. Why is it fine at the front but not back? Hmmmm. – Merle_the_Pearl Feb 22 '22 at 22:30
  • 1
    @Merle_the_Pearl - When it is the first parameter, there is no `&` in front. `times` alone is not considered an html entity, but `&times` is. – SOS Feb 22 '22 at 23:22
  • @user12031119 : No Go : symbol=SHIBUSDT&side=sell&type=market&quantity=9005×tamp=1645573615219 – Merle_the_Pearl Feb 22 '22 at 23:49
  • Fixed with : & : – Merle_the_Pearl Feb 22 '22 at 23:58
  • The actual string still contains `&time` - not `x`. Is it really causing a problem elsewhere, or just confusing when displayed on screen for debugging? https://trycf.com/gist/1ad70da80237605e9e72e881ecab714a/acf2016?theme=monokai – SOS Feb 23 '22 at 00:27
  • For example, it might display correctly on screen, but if used as a url query string, the url parameter name would become `&timestamp` rather than `timestamp`. So could you clarify what type of issues it's causing (other than displaying incorrectly on screen)? – SOS Feb 23 '22 at 03:18

1 Answers1

1

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.

SOS
  • 6,430
  • 2
  • 11
  • 29