使用Coldfusion签署API请求

时间:2011-11-10 13:58:56

标签: coldfusion

我正在尝试使用Kelkoo API(http://developer.kelkoo.com/samples/)作为项目的一部分,在签署我的请求时,我遇到了障碍。< / p>

与Coldfusion一样(遗憾的是!)没有代码样本,尽管研究了其他样本,但我真的不知道如何构建它(即他们实际上并没有在任何地方说出他们想要的东西! )。

也许我错过了一些东西,但是正确方向的任何指针都会受到赞赏!

2 个答案:

答案 0 :(得分:1)

使用Java作为样本:http://developer.kelkoo.com/samples/signing-url-java/

  1. var你的变量
  2. System.currentTimeMillis()=&gt; getTickCount()
  3. + string concat =&gt; & string concat
  4. 第41行:tokken = hash(URLtmp & key, "md5", "ISO-8859-1")
  5. hash()会返回十六进制,因此您需要toBase64(BinaryDecode(tokken, "hex"))
  6. 第42行:replaceList(tokken, "+,/,=", ".,_,-")

答案 1 :(得分:0)

                          

    <cfargument name="urlDomain" type="string" required="false" default="http://fr.shoppingapis.kelkoo.com" hint="kelkoo API domain"/>

    <!---
     Signature Kelkoo URL

        @param urlPath string (required) kelkoo path resources (ex: /V3/productSearch?query=table)
        @param secretKey string (required) kelkoo Secret Key 
        @param trackingId string (required) kelkoo tracking Id

        @param urlDomain    string (optional) kelkoo API domain default (http://fr.shoppingapis.kelkoo.com)

        @author Mauro Cardini (mcardini@decofinder.com) 
        @version 0, December, 2019 
    --->


    <cfset var theTimeStamp=int(getTickCount()/1000)>

    <cfset var URLtmp=arguments.urlPath & "&aid="& arguments.trackingId & "&timestamp=" & theTimeStamp>

     <cfset var tokken=hash(URLtmp & arguments.secretKey, "md5", "UTF-8")>

     <cfset tokken=toBase64(BinaryDecode(tokken, "hex"))>
     <cfset var thetokken=replaceList(tokken, "+,/,=", ".,_,-")>
     <cfset URLreturn = arguments.urlDomain & URLtmp & "&hash=" & theTokken>


<cfreturn URLreturn>