首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >常量联系人API - (403)禁止添加新联系人

常量联系人API - (403)禁止添加新联系人
EN

Stack Overflow用户
提问于 2012-07-14 01:50:18
回答 1查看 456关注 0票数 0

我正在尝试使用Constant contact API将新联系人添加到邮件列表中。我有一个简单的asp.net表单,正在执行下面的函数,但是我得到了"The remote server returned an error:(403) form“。我的功能直接来自于不断的接触,但请看图!

Constant Contact API

代码语言:javascript
复制
Public Function AddContact(ByVal UserEmailAddress As String, ByVal ContactListNumber As Integer) As String
    Try
        Dim xml As String
        xml = "<?xml version='1.0' encoding='utf-8' ?>" & _
        "<entry xmlns='http://www.w3.org/2005/Atom'>" & _
            "<title type='text'></title>" & _
            "<updated>2008-07-23T14:21:06.407Z</updated>" & _
            "<author></author>" & _
            "<id>data:,none</id>" & _
            "<summary type='text'>Contact</summary>" & _
            "<content type='application/vnd.ctct+xml'>" & _
                "<Contact xmlns='http://ws.constantcontact.com/ns/1.0/'>" & _
                    "<EmailAddress>" & UserEmailAddress.ToString() & "</EmailAddress>" & _
                    "<OptInSource>ACTION_BY_CONTACT</OptInSource>" & _
                    "<ContactLists>" & _
                        "<ContactList id='http://api.constantcontact.com/ws/customers/[username]/lists/" & ContactListNumber.ToString() & "'/>" & _
                    "</ContactLists>" & _
                "</Contact>" & _
            "</content>" & _
        "</entry>"

        ' Set up the request
        Dim request As HttpWebRequest
        request = WebRequest.Create("https://api.constantcontact.com/ws/customers/[username]/contacts/")
        Dim byteData As Byte() = UTF8Encoding.UTF8.GetBytes(xml.ToString())
        request.Method = "POST"
        request.ContentType = "application/atom+xml"
        request.ContentLength = byteData.Length
        request.Credentials = New NetworkCredential("[api key]%[username]", "[password]")

        ' Send the request
        Dim postStream As Stream
        postStream = request.GetRequestStream()
        postStream.Write(byteData, 0, byteData.Length)

        Dim response As HttpWebResponse
        response = request.GetResponse()

    Catch ex As WebException
        Return ex.ToString
    End Try
End Function
EN

回答 1

Stack Overflow用户

发布于 2012-11-09 10:21:39

403 error for constant contact表示密码错误,或者密码字符串配置错误。它们为其身份验证指定[your_api_key]%[your_constantcontact_username]:[password]。尽管他们说这已经过时了,每个人现在都应该转向oauth 2.0 (或者至少在2013年前)。这样你就不再需要传递密码了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11475697

复制
相关文章

相似问题

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