2012-02-19 78 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