向 Stripe API 发送 http 调用以获取 Auth-token,但以下代码引发错误:开始标记必须具有匹配的结束标记。可以通过添加</cffunction>
. 如果标签的正文为空,则可以使用快捷方式<cffunction .../>.....
<cffunction name="getAuthToken" access="private" output="false">
<cfhttp url="#variables.server#/v1/tokens" method="post" password="#variables.password#">
<cfargument name="req" required="true" type="any">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
<cfhttpparam type="header" name="Accept-Language" value="en_US">
<cfhttpparam type="body" value="#req#">
</cfhttp>
<cfset response = deserializeJSON(cfhttp.FileContent)>
<cfreturn response>
</cffunction>
Run Code Online (Sandbox Code Playgroud)
在我看来,你的<cfargument ...
标签放错了地方。编译器对此感到困惑。<cffunction ...
而是将它移到标签下。
像这样:
<cffunction name="getAuthToken" access="private" output="false">
<cfargument name="req" required="true" type="any">
<cfhttp url="#variables.server#/v1/tokens" method="post" password="#variables.password#">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
<cfhttpparam type="header" name="Accept-Language" value="en_US">
<cfhttpparam type="body" value="#req#">
</cfhttp>
<cfset response = deserializeJSON(cfhttp.FileContent)>
<cfreturn response>
</cffunction>
Run Code Online (Sandbox Code Playgroud)
除非它打算成为另一个,<cfhttpparam ...
在这种情况下将其更改为。