当前位置: 首页>>代码示例>>C#>>正文


C# ConstantContactUtility.AuthenticationData类代码示例

本文整理汇总了C#中ConstantContactUtility.AuthenticationData的典型用法代码示例。如果您正苦于以下问题:C# AuthenticationData类的具体用法?C# AuthenticationData怎么用?C# AuthenticationData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationData类属于ConstantContactUtility命名空间,在下文中一共展示了AuthenticationData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     //DEBUG TESTING
     AuthenticationData authdata = new AuthenticationData();  //Set your credentials for basic or OAuth2 inside the parentheses
   
     //Your test code below
 }
开发者ID:shannon7wallace,项目名称:.NET-wrapper-with-OAuth2,代码行数:7,代码来源:Form1.cs

示例2: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     //DEBUG TESTING
     AuthenticationData authdata = new AuthenticationData();
     authdata.Username = "";
     authdata.Password = "";
     authdata.ApiKey = "";
 }
开发者ID:zeiddev,项目名称:Constant-Contact-Dot-Net-Wrapper,代码行数:8,代码来源:Form1.cs

示例3: IsValidUserAuthentication

        /// <summary>
        /// Verify user authentication
        /// </summary>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <exception cref="ConstantAuthenticationException">Thrown if communication error with Constant server occur 
        /// or other related with the response from server 
        /// or if ApiKey, Username or Password are null or empty</exception>
        public static void IsValidUserAuthentication(AuthenticationData authenticationData)
        {
            ValidateAuthenticationData(authenticationData);

            try
            {
                // try to access the Service Document resource
                // it will throw a WebException if Constant Contact credentials are invalid

                GetResponseStream(new Uri(authenticationData.AccountServiceDocumentUri), authenticationData);
            }
            catch (Exception e)
            {
                throw new ConstantAuthenticationException("Account authentication failed", e,
                                                          authenticationData.Username);
            }
        }
开发者ID:shannon7wallace,项目名称:.NET-wrapper-with-OAuth2,代码行数:24,代码来源:Utility.cs

示例4: GetUserContactListCollection

        /// <summary>
        /// Retrieves the collection of user Contact Lists returned by the server at current chunk Id.        
        /// The collection is sorted by the Sort Order and it will not include the system 
        /// predefined lists ("Active", "Removed", "DoNotEmail")
        /// </summary>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <param name="currentChunkId">Link to the current chunk data</param>
        /// <param name="nextChunkId">Link to the next chunk of data</param>
        /// <exception cref="ConstantException">Thrown if communication error with Constant server occur 
        /// or other related with the response from server
        /// or if ApiKey, Username or Password are null or empty</exception>
        /// <returns>The collection of user Contact Lists</returns>
        public static IList<ContactList> GetUserContactListCollection(AuthenticationData authenticationData, string currentChunkId, out string nextChunkId)
        {
            // get the collection of Contact Lists
            IList<ContactList> list = GetContactListCollection(authenticationData, currentChunkId, out nextChunkId);

            IList<ContactList> nonSystemList = new List<ContactList>();

            foreach (ContactList contactList in list)
            {
                if (!contactList.IsSystemList)
                {
                    nonSystemList.Add(contactList);
                }
            }

            return nonSystemList;
        }
开发者ID:jethomas84,项目名称:Constant-Contact-Dot-Net-ASP-Contact-Forms,代码行数:29,代码来源:Utility.cs

示例5: RemoveContactFromAllLists

        /// <summary>
        /// Remove Contact from all Contact Lists
        /// </summary>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <param name="contactId">Contact Id</param>
        /// <exception cref="ArgumentException">Thrown if Id of specified Contact is null or empty</exception>        
        /// <exception cref="ConstantException">Thrown if communication error with Constant server occur 
        /// or other related with the response from server or if no Contact with specified Id exists
        /// or if ApiKey, Username or Password are null or empty</exception>
        public static void RemoveContactFromAllLists(AuthenticationData authenticationData, string contactId)
        {
            ValidateAuthenticationData(authenticationData);

            if (string.IsNullOrEmpty(contactId))
            {
                throw new ArgumentException("Contact Id cannot be null or empty", "contactId");
            }

            // create the URI for specified Contact Id
            string completeUri = String.Format(CultureInfo.InvariantCulture, "{0}/{1}",
                                               authenticationData.AccountContactsUri, contactId);

            // get Contact by Id
            Contact contact = GetContactDetailsById(authenticationData, contactId);

            // consider that Contact does not needs to be updated
            bool needUpdate = false;

            if (contact.ContactLists.Count != 0)
            {
                // remove Contact from all Contact Lists
                contact.ContactLists.Clear();

                // Contact must be updated
                needUpdate = true;
            }

            if (!needUpdate)
            {
                // no need to update Contact
                return;
            }

            // get the Atom entry for specified Contact
            StringBuilder data = ContactComponent.RemoveContactFromAllLists(contact,
                                                                            authenticationData.AccountContactsUri);

            try
            {
                // put the Atom entry at specified Uri
                PutInformation(authenticationData, new Uri(completeUri), data.ToString());
            }
            catch (Exception e)
            {
                // possible that the Contact does not exist any more; not sure if this could happened
                if (string.Compare(e.Message, WebExceptionCode404Message) == 0)
                {
                    throw new ConstantException(String.Format(CultureInfo.InvariantCulture,
                                                              "Contact with Id '{0}' does not exist.", contactId));
                }

                throw new ConstantException(e.Message, e);
            }
        }
开发者ID:jethomas84,项目名称:Constant-Contact-Dot-Net-ASP-Contact-Forms,代码行数:64,代码来源:Utility.cs

示例6: GetResponseStream

        /// <summary>
        /// Sends a Http GET request and returns the response Stream from the specified Uri address
        /// </summary>
        /// <param name="address">Uri address</param>     
        /// <param name="authenticationData">Authentication data</param>
        /// <returns>Response Stream</returns>
        private static Stream GetResponseStream(Uri address, AuthenticationData authenticationData)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
            request.Credentials = CreateCredentialCache(address, authenticationData);
            request.Method = WebRequestMethods.Http.Get;

            // request MUST include a WWW-Authenticate
            request.PreAuthenticate = true;

            Stream stream = Stream.Null;
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                // get the response Stream
                stream = response.GetResponseStream();

                // read the response stream and save it into a memory stream
                return ReadResponseStream(stream);
            }
            catch (WebException e)
            {
                if (null != e.Response)
                {
                    Console.Out.WriteLine("WebException Response Headers =");
                    Console.Out.WriteLine(e.Response.Headers);
                }
                throw;
            }
            finally
            {
                if (stream != Stream.Null)
                {
                    // close response stream; it also closes the web response
                    stream.Close();
                }
            }
        }
开发者ID:jethomas84,项目名称:Constant-Contact-Dot-Net-ASP-Contact-Forms,代码行数:44,代码来源:Utility.cs

示例7: deleteList

        /// <summary>
        /// Delete a Contact List specified by list ID
        /// </summary>
        /// <param name="authdata">Authentication data (username, password and API Key)</param>
        /// <param name="listID">ID of target list to delete</param> 
        public static void deleteList(AuthenticationData authdata, string listID)
        {
            if (string.IsNullOrEmpty(listID))
            {
                throw new ArgumentException("List Id cannot be null or empty", "id");
            }
            try
            {
                httpDelete(authdata, authdata.AccountContactListsUri + "/" + listID);
            }
            catch (Exception e)
            {
                if (string.Compare(e.Message, WebExceptionCode404Message) == 0)
                {
                    throw new ConstantException(String.Format(CultureInfo.InvariantCulture,
                                                              "List with ID '{0}' does not exist.", listID));
                }

                throw new ConstantException(e.Message, e);
            }
        }
开发者ID:withinboredom,项目名称:Constant-Contact-Dot-Net-Wrapper,代码行数:26,代码来源:Utility.cs

示例8: DeleteInformation

        /// <summary>
        /// Sends a Http DELETE request at the specified Uri address
        /// </summary>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <param name="address">Uri address</param>
        private static void DeleteInformation(AuthenticationData authenticationData, Uri address)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
            request.Credentials = CreateCredentialCache(address, authenticationData);

            request.Method = "DELETE";

            HttpWebResponse response = null;
            try
            {
                response = (HttpWebResponse)request.GetResponse();
                Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
                                                "Method {0}, response description: {1}", request.Method,
                                                response.StatusDescription));
            }
            finally
            {
                if (response != null)
                {
                    // close the response
                    response.Close();
                }
            }
        }
开发者ID:jethomas84,项目名称:Constant-Contact-Dot-Net-ASP-Contact-Forms,代码行数:29,代码来源:Utility.cs

示例9: UnsubscribeContact

        /// <summary>
        /// Opting-out ("Unsubscribe") a Contact
        /// </summary>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <param name="contactId">Contact Id</param>
        /// <exception cref="ArgumentException">Thrown if Id of specified Contact is null or empty</exception>        
        /// <exception cref="ConstantException">Thrown if communication error with Constant server occur 
        /// or other related with the response from server or if no Contact with specified Id exists
        /// or if ApiKey, Username or Password are null or empty</exception>
        /// <remarks>Opted-out Contacts become members of the Do-Not-Mail special list</remarks>
        public static void UnsubscribeContact(AuthenticationData authenticationData, string contactId)
        {
            ValidateAuthenticationData(authenticationData);

            if (string.IsNullOrEmpty(contactId))
            {
                throw new ArgumentException("Contact Id cannot be null or empty", "contactId");
            }

            // create the URI for specified Contact List Id
            string completeUri = String.Format(CultureInfo.InvariantCulture, "{0}/{1}",
                                               authenticationData.AccountContactsUri, contactId);

            try
            {
                // issue a Http DELETE and specified Uri
                DeleteInformation(authenticationData, new Uri(completeUri));
            }
            catch (Exception e)
            {
                // possible that the Contact does not exist any more
                if (string.Compare(e.Message, WebExceptionCode404Message) == 0)
                {
                    throw new ConstantException(String.Format(CultureInfo.InvariantCulture,
                                                              "Contact with Id '{0}' does not exist.", contactId));
                }

                throw new ConstantException(e.Message, e);
            }
        }
开发者ID:jethomas84,项目名称:Constant-Contact-Dot-Net-ASP-Contact-Forms,代码行数:40,代码来源:Utility.cs

示例10: UpdateContactSmallForm

 /// <summary>
 /// Update a Contact using the simplified form. Only the following fields will be updated: 
 /// EmailAddress, FirstName, LastName, MiddleName, HomePhone, Addr1, Addr2, Addr3,
 /// City, StateCode, StateName, CountryCode, CountryName, PostalCode, SubPostalCode
 /// </summary>
 /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
 /// <param name="contact">Contact to be updated</param>
 /// <exception cref="ArgumentNullException">Thrown if specified Contact is null</exception>
 /// <exception cref="ArgumentException">Thrown if Id or Email Address of specified Contact is null or empty</exception>        
 /// <exception cref="ConstantException">Thrown if communication error with Constant server occur 
 /// or other related with the response from server, if no Contact with specified Id exists 
 /// or if Contact cannot be updated (it belongs to the Do-Not-Mail list)
 /// or if ApiKey, Username or Password are null or empty</exception>        
 public static void UpdateContactSmallForm(AuthenticationData authenticationData, Contact contact)
 {
     UpdateContact(authenticationData, contact, false);
 }
开发者ID:jethomas84,项目名称:Constant-Contact-Dot-Net-ASP-Contact-Forms,代码行数:17,代码来源:Utility.cs

示例11: GetEmailCampaignCollection

        /// <summary>
        /// Gets a list of email campaigns filtered by status
        /// </summary>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <param name="status">campaign status</param>
        /// <returns>filtered email campaigns</returns>
        public static List<EmailCampaign> GetEmailCampaignCollection(AuthenticationData authenticationData, string status)
        {
            string currentAddress = string.Format("{0}?status={1}", authenticationData.AccountEmailCampaignsListUri, status);

            Stream stream = Stream.Null;
            try
            {
                // get the response stream
                stream = GetResponseStream(new Uri(currentAddress), authenticationData);

                // parse the stream and get a collection of Contact Lists
                return EmailCampaignComponent.GetEmailCampaignCollection(stream);
            }
            catch (Exception e)
            {
                throw new ConstantException(e.Message, e);
            }
            finally
            {
                // close the response stream
                stream.Close();
            }
        }
开发者ID:withinboredom,项目名称:Constant-Contact-Dot-Net-Wrapper,代码行数:29,代码来源:Utility.cs

示例12: SearchContactByEmail

        /// <summary>
        /// Retrieves the first chunk collection of Contacts that match specified Email Addresses
        /// </summary>
        /// <remarks>Constant Contact server provides paged collections</remarks>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <param name="emailAddresses">One or more Email Addresses</param>
        /// <param name="nextChunkId">Link to the next chunk of data</param>
        /// <exception cref="ConstantException">Thrown if communication error with Constant server occur 
        /// or other related with the response from server 
        /// or if ApiKey, Username or Password are null or empty</exception>
        /// <returns>The collection of Contacts</returns>
        public static IList<Contact> SearchContactByEmail(AuthenticationData authenticationData, IEnumerable<string> emailAddresses, out string nextChunkId)
        {
            ValidateAuthenticationData(authenticationData);

            return SearchContactByEmail(authenticationData, emailAddresses, null, out nextChunkId);
        }
开发者ID:jethomas84,项目名称:Constant-Contact-Dot-Net-ASP-Contact-Forms,代码行数:17,代码来源:Utility.cs

示例13: GetEmailCampaignById

        /// <summary>
        /// Get EmailCampaign By Id
        /// </summary>
        /// <param name="authenticationData">Authentication data (username, password and API Key)</param>
        /// <param name="id">campaign id</param>
        /// <returns>Email campaign with the specified id</returns>
        public static EmailCampaign GetEmailCampaignById(AuthenticationData authenticationData, string id)
        {
            string currentAddress = string.Format("{0}/{1}", authenticationData.AccountEmailCampaignsListUri, id);

            Stream stream = Stream.Null;
            try
            {
                // get the response stream
                stream = GetResponseStream(new Uri(currentAddress), authenticationData);

                // parse the stream and get an Email Campaign
                return EmailCampaignComponent.GetEmailCampaign(stream);
            }
            catch (Exception e)
            {
                throw new ConstantException(e.Message, e);
            }
            finally
            {
                // close the response stream
                stream.Close();
            }
        }
开发者ID:withinboredom,项目名称:Constant-Contact-Dot-Net-Wrapper,代码行数:29,代码来源:Utility.cs

示例14: getActivityDetails

 /// <summary>
 /// Get details of activity with specified ID
 /// </summary>
 /// <param name="Authdata">Authentication Data</param>
 /// <param name="id">ID of target activity</param>
 /// <returns>Returns details of activity of specified id</returns>
 public static Activity getActivityDetails(AuthenticationData Authdata, string id)
 {
     //verify id was specified
     if (string.IsNullOrEmpty(id))
     {
         throw new ArgumentException("Activity Id cannot be null or empty", "id");
     }
     string blank = "";
     string fullcall = Authdata.accountActivitiesUri + "/" + id;
     //return Activity
     return getActivities(Authdata, id, out blank)[0];
 }
开发者ID:withinboredom,项目名称:Constant-Contact-Dot-Net-Wrapper,代码行数:18,代码来源:Utility.cs

示例15: getActivities

        /// <summary>
        /// Gets chunk of activites at specified link
        /// </summary>
        /// <param name="Authdata">Authentication Data</param>
        /// <param name="link">Link to target chunk of data</param>
        /// <param name="nextChunk">out link to next chunk of data</param>
        /// <returns>returns list up to 50 activities of specified chunk. if more than 50, out nextChunk link to next chunk of data</returns>
        public static IList<Activity> getActivities(AuthenticationData Authdata, string link, out string nextChunk)
        {
            //Create new xmldocument, create activitieslist uri, GET, load XML.
            XmlDocument xDoc = new XmlDocument();
            string URI = "";
            if (link == "")
            {
                URI = Authdata.accountActivitiesUri;
            }
            else
            {
                URI = Authdata.ApiRootUri + link;
            }
            try
            {
                xDoc.LoadXml(Utility.httpGet(Authdata, URI));
                //Define namespaces
                XmlNamespaceManager xnsmgr = new XmlNamespaceManager(xDoc.NameTable);
                xnsmgr.AddNamespace("ns1", "http://www.w3.org/2005/Atom");
                xnsmgr.AddNamespace("ns2", "http://ws.constantcontact.com/ns/1.0/");
                //Check for link to next chunk of data. If no next chunk, return empty string.
                nextChunk = "";
                XmlNodeList xnlLinks = xDoc.SelectNodes("//ns1:link", xnsmgr);
                foreach (XmlNode xnLink in xnlLinks)
                {
                    if (xnLink.Attributes["rel"] != null)
                    {
                        if (xnLink.Attributes["rel"].Value == "next")
                        {
                            nextChunk = xnLink.Attributes["href"].Value;
                        }
                    }
                }
                //Select nodes
                XmlNodeList xnlActivities = xDoc.SelectNodes("//ns2:Activity", xnsmgr);
                //parse XML
                IList<Activity> Activities = new List<Activity>();
                foreach (XmlNode xnMember in xnlActivities)
                {
                    Activity activity = new Activity();

                    XmlNode xnName = xnMember.SelectSingleNode("../../ns1:title", xnsmgr);
                    activity.activityName = xnName.InnerText;

                    XmlNode xnID = xnMember.SelectSingleNode("../../ns1:id", xnsmgr);
                    activity.activityId = xnID.InnerText;

                    XmlNode xnUpdated = xnMember.SelectSingleNode("../../ns1:updated", xnsmgr);
                    activity.updated = xnUpdated.InnerText;

                    XmlNode xnLink = xnMember.SelectSingleNode("../../ns1:link", xnsmgr);
                    activity.activityLink = xnLink.Attributes["href"].Value;

                    XmlNode xnType = xnMember.SelectSingleNode("ns2:Type", xnsmgr);
                    activity.Type = xnType.InnerText;

                    XmlNode xnStatus = xnMember.SelectSingleNode("ns2:Status", xnsmgr);
                    activity.Status = xnStatus.InnerText;

                    XmlNode xnTransactions = xnMember.SelectSingleNode("ns2:TransactionCount", xnsmgr);
                    activity.transactionCount = xnTransactions.InnerText;

                    XmlNode xnErrors = xnMember.SelectSingleNode("ns2:Errors", xnsmgr);
                    activity.Errors = xnErrors.InnerText;

                    XmlNode xnRunStart = xnMember.SelectSingleNode("ns2:RunStartTime", xnsmgr);
                    activity.runStartTime = xnRunStart.InnerText;

                    XmlNode xnRunFinish = xnMember.SelectSingleNode("ns2:RunFinishTime", xnsmgr);
                    activity.runFinishTime = xnRunFinish.InnerText;

                    XmlNode xnInsert = xnMember.SelectSingleNode("ns2:InsertTime", xnsmgr);
                    activity.insertTime = xnInsert.InnerText;

                    Activities.Add(activity);
                }
                return Activities;
            }
            catch (Exception e)
            {
                if (string.Compare(e.Message, WebExceptionCode404Message) == 0)
                {
                    throw new ConstantException(String.Format(CultureInfo.InvariantCulture,
                                                              "Activity at link '{0}' does not exist.", link));
                }

                throw new ConstantException(e.Message, e);

            }
        }
开发者ID:withinboredom,项目名称:Constant-Contact-Dot-Net-Wrapper,代码行数:97,代码来源:Utility.cs


注:本文中的ConstantContactUtility.AuthenticationData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。