首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将curl转换为cfx_http5

将curl转换为cfx_http5
EN

Stack Overflow用户
提问于 2012-02-19 23:17:08
回答 1查看 700关注 0票数 0

请帮助将此curl命令转换为cfx_http5命令

代码语言:javascript
复制
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">
EN

回答 1

Stack Overflow用户

发布于 2012-02-21 23:09:35

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

代码语言:javascript
复制
<!--- 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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9350406

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档