перевести curl в cfx_http5 - PullRequest
       19

перевести curl в cfx_http5

0 голосов
/ 19 февраля 2012

Помогите пожалуйста перевести эту команду 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 голосов
/ 21 февраля 2012

Вы можете вручную выполнить дайджест-аутентификацию вместо использования 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...