将MailGun cUrl转换为Coldfusion

将MailGun cUrl转换为Coldfusion

问题描述:

我正在尝试使用Coldfusion对Mailgun邮件列表执行操作.

I'm attempting to perform actions on a Mailgun mailing list using Coldfusion.

Mailgun提供了以下密码:

Mailgun have supplied the following cUrl:

curl -s --user 'api:key-xxxMyAPIkeyxxx' -G \
https://api.mailgun.net/v3/lists/myList@myDomain.mailgun.org/members

只需输入

https://api:key-xxxmyAPIkeyxxx@api.mailgun.net/v3/lists/myList@myDomain.mailgun.org/members

但是我没有运气将其转换为CFHTTP调用:

But I've had no luck converting this into a CFHTTP call:

<cfhttp url="https://api:key-xxxmyAPIkey@api.mailgun.net/v3/lists/myList@myDomain.mailgun.org/members" method="GET" result="resultName">

<cfdump var="#resultName#">

这将返回全部错误:

对象 ErrorDetail [字符串]
Mimetype [string]应用程序/json 状态码[字符串] 401未经授权 文件内容[对象]
对象[空] Responseheader [对象] 目的 连接[字符串]关闭 内容长度[数字] 0 日期[string] 2015年8月10日,星期一16:46:22 GMT 说明[string]未经授权 内容类型[string] application/json Http_Version [字符串] HTTP/1.1 Www-Authenticate [string] Basic realm ="MG API" 服务器[string] nginx/1.7.9 状态码[编号] 401 文字[布尔]假 字符集[string]
标头[string] HTTP/1.1 401未经授权,内容类型:application/json连接:关闭日期:2015年8月10日,星期一,格林尼治标准时间www.www-authenticate:Basic realm ="MG API"内容长度:0服务器: nginx/1.7.9

object ErrorDetail [string]
Mimetype [string] application/json Statuscode [string] 401 Unauthorized Filecontent [object]
object [empty] Responseheader [object] object Connection [string] close Content-Length [number] 0 Date [string] Mon, 10 Aug 2015 16:46:22 GMT Explanation [string] Unauthorized Content-Type [string] application/json Http_Version [string] HTTP/1.1 Www-Authenticate [string] Basic realm="MG API" Server [string] nginx/1.7.9 Status_Code [number] 401 Text [boolean] false Charset [string]
Header [string] HTTP/1.1 401 Unauthorized Content-Type: application/json Connection: close Date: Mon, 10 Aug 2015 16:46:22 GMT Www-Authenticate: Basic realm="MG API" Content-Length: 0 Server: nginx/1.7.9

任何想法

Mailgun API 表示使用基本身份验证.尝试通过 usernamepassword属性提供凭据,而不是通过网址:

The Mailgun API says basic authentication is used. Try supplying the credentials via the username and password attributes instead of the URL:

<cfhttp url="https://api.mailgun.net/v3/lists/myList@myDomain.mailgun.org/members" 
      method="GET" 
      username="api" 
      password="key-xxxYourAPIKeyxxx"
      result="resultName" />