2012-02-19 82 views
0

在翻译这个curl命令来cfx_http5命令翻译卷曲cfx_http5

HTTP method: PUT 
URL: http://webapi.ebayclassifieds.com/webapi/partners/{username}/ads/{ext-reference-id} 
Sample command: 

curl --digest -u{username}:{password} -v -X PUT -H 'Expect: ' -H 'Content-type: application/xml' -d @- http://webapi.ebayclassifieds.com/webapi/partners/{username}/ads/{ext-reference-id} < ad.xml 
[Note: - The "ext-reference-id"" is the unique identifier of the ad and should be used for updating and deleting the ad.] 

<CFX_HTTP5 username="myusername" password="mypassword" URL="http://webapi.ebayclassifieds.com/webapi/partners/{username}/ads/{ext-reference-id}" OUT="theresponse" METHOD="PUT"> 
+1

Cfhttp不适合你吗? – Henry 2012-02-20 16:31:01

+0

cfhttp不允许摘要认证,这就是为什么我们使用cfx_http5 – Vlad 2012-02-20 18:50:22

+0

我不知道如何使用CFX_HTTP5标签,但是这个人似乎已经分享了你的问题,并通过打击java - http://www.terrenceryan解决。 com/blog/post.cfm/digest-authentication-in-coldfusion – 2012-02-20 20:37:01

回答

0

请帮您可以手动完成的,而不是使用http5摘要身份验证。可能可以使用一些调整,并为您需要额外的标头添加额外的cfhttpparam行:

<!--- dummy request to get nonce and domain. ---> 
<cfhttp url="http://#URLroot#/#RestOfUrl#" method="POST" > 
<cfhttpparam type="body" value=""> 
</cfhttp> 
<cfset noncestart = find('nonce="',cfhttp.Header)+7> 
<cfset nonceend = find('"',cfhttp.Header,noncestart)> 
<cfset nonce = mid(cfhttp.header,noncestart,nonceend-noncestart)> 
<cfset Realmstart = find('realm="',cfhttp.Header)+7> 
<cfset Realmend = find('"',cfhttp.Header,Realmstart)> 
<cfset Realm = mid(cfhttp.header,noncestart,nonceend-noncestart)> 
<cfset Hash1 = lcase(Hash("#user#:#Realm#:#pass#","MD5"))> 
<cfset Hash2 = lcase(Hash("POST:/#RestOfUrl#", "MD5"))> 
<cfset Response = lCase(Hash("#Hash1#:#Nonce#:#Hash2#", "MD5"))> 
<cfset Auth = 'Digest username="#user#", realm="#Realm#", nonce="#nonce#", uri="/#RestOfUrl#", response="#Response#"'> 
<!--- Real request using Auth in Header. ---> 
<cfhttp url="http://#URLroot#/#RestOfUrl#" method="POST"> 
<cfhttpparam name="Authorization" type="header" value="#Auth#"> 
<cfhttpparam type="body" value="#postValue#"> 
</cfhttp> 
+0

谢谢杰西我会尝试一下,让你知道它是否有效。我真正的问题是翻译cUrl命令。 – Vlad 2012-02-22 01:05:11