Example #1
0
        protected void btnGetLeads_Click(object sender, EventArgs e)
        {
            #region make the GetLeads Call
            string leadKey = txtLeadID.Text;

            Marketo_WS_2_0.ResultGetLead resultGetLead = new Marketo_WS_2_0.ResultGetLead();

            string result = GetLeads(leadKey, ref resultGetLead);
            #endregion

            #region Display the Lead info on the screen


            lblResult.Text = "";

            string allLeads = "";

            if (result.Length > 0)
            {
                allLeads = result;
            }
            else if (resultGetLead.count == 0)
            {
                allLeads = "No Lead(s) Found";
            }
            else
            {
                Marketo_WS_2_0.LeadRecord[] leadRecs = resultGetLead.leadRecordList;

                allLeads = "";

                foreach (Marketo_WS_2_0.LeadRecord leadRecord in leadRecs)
                {
                    allLeads = allLeads + @"<br/><b>" + leadRecord.Email + @"</b><br/>";
                    foreach (Marketo_WS_2_0.Attribute attrib in leadRecord.leadAttributeList)
                    {
                        allLeads = allLeads + attrib.attrName + " - " + attrib.attrValue + @"<br/>";
                    }
                }
            }



            lblResult.Text = allLeads;
            #endregion
        }
Example #2
0
        private string GetLeads(string LeadID, ref Marketo_WS_2_0.ResultGetLead rs)
        {
            Marketo_WS_2_0.SuccessGetLead response = new Marketo_WS_2_0.SuccessGetLead();

            string results = "";

            string userID        = txtUserID.Text;
            string EncryptionKey = txtEncryptionID.Text;



            string requestTimeStamp = ConvertDateToW3CTime(DateTime.Now);

            string stringToEncrypt = requestTimeStamp + userID;


            string message;
            string key;

            key     = EncryptionKey;
            message = stringToEncrypt;

            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            byte[] keyByte = encoding.GetBytes(key);

            HMACSHA1 hmacsha1 = new HMACSHA1(keyByte);

            byte[] messageBytes = encoding.GetBytes(message);

            byte[] hashmessage = hmacsha1.ComputeHash(messageBytes);

            string header = ByteToString(hashmessage);



            Marketo_WS_2_0.AuthenticationHeaderInfo ws_header = new Marketo_WS_2_0.AuthenticationHeaderInfo();
            ws_header.mktowsUserId     = userID;
            ws_header.requestSignature = header.ToLower();
            ws_header.requestTimestamp = requestTimeStamp;

            Marketo_WS_2_0.ParamsGetLead ws_lead    = new Marketo_WS_2_0.ParamsGetLead();
            Marketo_WS_2_0.LeadKey       ws_leadkey = new Marketo_WS_2_0.LeadKey();
            ws_leadkey.keyType  = Marketo_WS_2_0.LeadKeyRef.IDNUM;
            ws_leadkey.keyValue = LeadID;
            ws_lead.leadKey     = ws_leadkey;



            try
            {
                response = client.getLead(ws_header, ws_lead);
                results  = "";
                rs       = response.result;
            }
            catch (Exception e)
            {
                results = e.Message;
                rs      = null;
            }


            return(results);
        }