将curl转换为cfx_http5

时间:2012-02-19 15:17:08

标签: curl coldfusion ebay

请帮助将此curl命令转换为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 个答案:

答案 0 :(得分: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>