我正在尝试执行一个cfhttp帖子,我需要在URL变量中包含一个URL,以指示将快递收据存放在哪里。
这是我的代码:
<cfhttp result="CFHTTP" method="GET" url="http://xxxxxxxxxxx/send-sms.php?sender=#numbers.number#&to=#get_sms.receiver#&message=#get_sms.msgdata#&dlr-url=#get_sms.dlr_url#">
<cfhttpparam type="formfield" name="sender" value="#numbers.number#">
<cfhttpparam type="formfield" name="to" value="#get_sms.receiver#">
<cfhttpparam type="formfield" name="message" value="#get_sms.msgdata#">
<cfhttpparam type="formfield" name="dlr-url" value="#get_sms.dlr_url#">
</cfhttp>
如果我不包括类似于以下的dlr_url,一切都会正常工作:
http://entry.xxxxxxxx.com/process_dlr.cfm?status=%d&msisdn=%p&dlr掩码=31&数据=%a&batchid=161F3CE3-E031-9CFF-7364A9C1AC50AA5B&目的地=2&accountID=123&sub_id=123456789&carrierID=2222
我只能假设像"以及"";会破坏这个过程。关于如何做到这一点,有什么想法吗?
谢谢大家的帮助。
这里有一些缺陷。
- 不要在
url
属性中手动指定查询参数。请改用<cfhttpparam param type="url"
GET
请求不支持主体(表单数据(,因此<cfhttpparam type="formfield"
不会执行任何操作- 为什么你甚至试图通过查询字符串AND主体发送相同的参数
如果使用正确的cfhttpparam
标记,则不必手动对值进行编码。
通过查询字符串正确请求参数
<cfhttp result="CFHTTP" method="GET" url="http://xxxxxxxxxxx/send-sms.php">
<cfhttpparam type="url" name="sender" value="#numbers.number#">
<cfhttpparam type="url" name="to" value="#get_sms.receiver#">
<cfhttpparam type="url" name="message" value="#get_sms.msgdata#">
<cfhttpparam type="url" name="dlr-url" value="#get_sms.dlr_url#">
</cfhttp>
通过查询字符串AND正文向params发出正确请求
<cfhttp result="CFHTTP" method="POST" url="http://xxxxxxxxxxx/send-sms.php">
<cfhttpparam type="url" name="sender" value="#numbers.number#">
<cfhttpparam type="url" name="to" value="#get_sms.receiver#">
<cfhttpparam type="url" name="message" value="#get_sms.msgdata#">
<cfhttpparam type="url" name="dlr-url" value="#get_sms.dlr_url#">
<cfhttpparam type="formfield" name="sender" value="#numbers.number#">
<cfhttpparam type="formfield" name="to" value="#get_sms.receiver#">
<cfhttpparam type="formfield" name="message" value="#get_sms.msgdata#">
<cfhttpparam type="formfield" name="dlr-url" value="#get_sms.dlr_url#">
</cfhttp>
不同之处在于:POST
允许查询字符串和正文有效载荷。GET
只允许查询字符串。
我想您对PHP更熟悉,所以以下是type
属性的翻译方式:
type="url" name="sender"
=>$_GET['sender']
- CCD_ 11=>
$_POST['sender']
我不知道我在想什么。。。。
需要编码:#URLEncodedFormat(get_sms.dlr_url)#
对不起,我没想到谢谢!!!