更新: 我设法使这件事正常工作!

事实证明,您需要发送带有通话的安全票,以获取正确的响应。我不知道为什么没有它在海报中起作用。还有其他几个参数,默认情况下,ColdFusion显然不会发送。

这是一个有效的电话:

<!---MyTicketValue is sent over from the SAML gateway--->
<cfset myTicket = #cookie.MyTicketValue#>

<!---here we set the XML for the POST--->
<cfsavecontent variable="APIxml"><qdbapi><ticket><cfoutput>#myTicket#</cfoutput></ticket><apptoken>c4abnsde36pse7hzurwvjjb4m</apptoken></qdbapi></cfsavecontent>

<!---and this is the post with all necessary headers (don't ask me why they're needed)--->
<cfhttp url="https://workplace.intuit.com/db/main" method="POST" result="objGet">
  <cfhttpparam type="header" name="Accept-Encoding" value="gzip,deflate"/>
  <cfhttpparam type="header" name="Keep-Alive" value="115" />
  <cfhttpparam type="header" name="QUICKBASE-ACTION" value="API_GetUserInfo" />
  <cfhttpparam type="header" name="Content-Type" value="application/xml; charset=UTF-8" />
  <cfhttpparam type="body" value="#APIxml#" />
</cfhttp>

这返回了Intuit工作场所的完美回应。


我试图通过ColdFusion致电给Intuit的API。呼叫必须发布给他们(通过SAML网关)。必须在标题中提供令牌。

我确实没有CFHTTP的经验,并且与整个API呼叫情况完全混淆。我在这里需要一些非常基本的帮助。

基本上,我如何格式化CFHTTP标签,以便可以在标题中使用此令牌?

<cfxml variable="API_GetUserInfo">

<qdbapi>
   <apptoken>c4abnsdepseds7hdzurwvjjb4m</apptoken>
   <email>email@hotmail.com</email>
</qdbapi>

</cfxml>


<cfhttp
  url="https://workplace.intuit.com/db/main"
  method="POST"
  result="objGet">

  <cfhttpparam
    type="header"
    name="Header"
    value="QUICKBASE-ACTION:API_GetUserInfo" 
  />

  <cfhttpparam
    type="xml"
    name="API_GetUserInfo"
    value="#API_GetUserInfo#"
  />

</cfhttp>

后来,我尝试了for Firefox的海报。

我可以接到电话正常的电话,但是当我尝试在CF中复制它时,我仍然无法得到答复。

这是更新的代码:

<cfhttp url="https://workplace.intuit.com/db/main" method="POST" result="objGet" >

<cfhttpparam type="header" name="QUICKBASE-ACTION" value="API_GetUserInfo" />

<cfhttpparam type="formfield" name="xml" value="#API_GetUserInfo#" />

</cfhttp>

在海报中,这是我进入的内容:

URL: https://workplace.intuit.com/db/main

内容类型:XML

内容:

<qdbapi>
  <apptoken>c4abnsdepseds7hdzurwvjjb4m</apptoken>
  <email>jimmyhogoboom@gmail.com</email>
</qdbapi>

和1个标题:

名称:QuickBase-Action

值:api_getuserinfo

通过这些设置,我得到了正确的响应。

关于ColdFusion代码我做错了什么的想法?

有帮助吗?

解决方案

知道了。您需要用ToString包裹XML。它将将XML声明放在XML的开头,以使其成为有效的XML文档。我只是尝试了它,它起作用了。

<cfhttpparam
    type="xml"
    name="API_GetUserInfo"
    value="#ToString(API_GetUserInfo)#"
/>

由于上述不起作用,我尝试了其他几件事,这是我所处的位置。我使用Fiddler监视海报提出的HTTP请求,我们知道这是一个很好的请求,这是请求标题:

POST https://workplace.intuit.com/db/main HTTP/1.1
Host: workplace.intuit.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
QUICKBASE-ACTION: API_GetUserInfo
Content-Type: application/xml; charset=UTF-8
Content-Length: 109
Cookie: scache=Jun  3 2010 18:30:57_3; ptest=1277297927934; stest=1277298582509
Pragma: no-cache
Cache-Control: no-cache

<qdbapi>
  <apptoken>c4abnsdepseds7hdzurwvjjb4m</apptoken>
  <email>jimmyhogoboom@gmail.com</email>
</qdbapi>

我尝试的下一件事是尽可能地模仿我的要求,但它仍然没有返回XML。您会注意到的一些事情是使用CFSAVECONTENT来摆脱XML声明,并添加了许多标头和Cookie属性来模拟海报请求:

<cfsavecontent variable="API_GetUserInfo"><qdbapi>
    <apptoken>c4abnsdepseds7hdzurwvjjb4m</apptoken>
    <email>jimmyhogoboom@gmail.com</email>
</qdbapi></cfsavecontent>

<cfhttp url="https://workplace.intuit.com/db/main" method="POST" result="objGet" useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)">
    <cfhttpparam type="header" name="Accept" value="application/xml" />
    <cfhttpparam type="header" name="Accept-Language" value="en-us,en" />
    <cfhttpparam type="header" name="Accept-Charset" value="utf-8" />
    <cfhttpparam type="header" name="Keep-Alive" value="115" />
    <cfhttpparam type="header" name="Connection" value="keep-alive" />
    <cfhttpparam type="header" name="QUICKBASE-ACTION" value="API_GetUserInfo" />
    <cfhttpparam type="header" name="Content-Type" value="application/xml; charset=UTF-8" />
    <cfhttpparam type="cookie" name="scache" value="Jun  3 2010 18:30:57_3" />
    <cfhttpparam type="cookie" name="ptest" value="1277297927934" />
    <cfhttpparam type="cookie" name="stest" value="1277298582509" />
    <cfhttpparam type="header" name="Pragma" value="no-cache" />
    <cfhttpparam type="header" name="Cache-Control" value="no-cache" />
    <!---<cfhttpparam encoded="no" type="formfield" name="" value="#API_GetUserInfo#" />--->
    <cfhttpparam type="body" value="#API_GetUserInfo#" />
</cfhttp>

CFHTTP没有按预期翻译某些属性,我只是不确定它是哪一个。也许第二套眼睛会有所帮助。可能必须直接使用CreateObject和Java(Java.net类)来执行HTTP请求和绕过CFHTTP,以及它添加到HTTP请求中导致其失败的每个默认值。

其他提示

只是在Intuit SDK页面上戳一下,看起来有一个 PHP开发套件 如果您有访问权限,可用。我会围绕HTTP调用,以了解如何在ColdFusion中构建类似的呼叫。因为您说“张贴”,因此通常会使用第二个CFHTTPPARAM标签的FormField类型,因为使用XML的类型会更改请求的结构和内容类型。

我也注意到一个 Java Saml Gateway 在他们的网站上,您可能可以将战争文件添加到您的网站上,并直接通过ColdFusion代码致电Java API。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top