private string SyncLead(string email, ref Marketo_WS_2_0.ResultSyncLead rs) { Marketo_WS_2_0.SuccessSyncLead response = new Marketo_WS_2_0.SuccessSyncLead(); 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.MktowsContextHeaderInfo ws_context = new Marketo_WS_2_0.MktowsContextHeaderInfo(); ws_context = null; 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.ParamsSyncLead ws_lead = new Marketo_WS_2_0.ParamsSyncLead(); Marketo_WS_2_0.LeadRecord LeadRec = new Marketo_WS_2_0.LeadRecord(); LeadRec.Email = email; Marketo_WS_2_0.Attribute[] attribList = new Marketo_WS_2_0.Attribute[2]; Marketo_WS_2_0.Attribute att1 = new Marketo_WS_2_0.Attribute(); att1.attrName = "FirstName"; att1.attrValue = "Joe"; attribList[0] = att1; Marketo_WS_2_0.Attribute att2 = new Marketo_WS_2_0.Attribute(); att2.attrName = "LastName"; att2.attrValue = "Smith"; attribList[1] = att2; LeadRec.leadAttributeList = attribList; ws_lead.leadRecord = LeadRec; LeadRec.Email = email; try { response = client.syncLead(ws_header, ws_context, ws_lead); results = ""; rs = response.result; } catch (Exception e) { results = e.Message; rs = null; } return(results); }
private string RequestCampaign(string MarketoID, string campaignID, ref Marketo_WS_2_0.ResultRequestCampaign rs) { Marketo_WS_2_0.SuccessRequestCampaign response = new Marketo_WS_2_0.SuccessRequestCampaign(); 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.MktowsContextHeaderInfo ws_context = new Marketo_WS_2_0.MktowsContextHeaderInfo(); ws_context = null; 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.ParamsRequestCampaign reqCampaign = new Marketo_WS_2_0.ParamsRequestCampaign(); reqCampaign.source = Marketo_WS_2_0.ReqCampSourceType.MKTOWS; reqCampaign.campaignId = int.Parse(campaignID); Marketo_WS_2_0.LeadKey[] leadList = new Marketo_WS_2_0.LeadKey[1]; Marketo_WS_2_0.LeadKey lk = new Marketo_WS_2_0.LeadKey(); lk.keyType = Marketo_WS_2_0.LeadKeyRef.IDNUM; lk.keyValue = MarketoID; leadList[0] = lk; reqCampaign.leadList = leadList; try { response = client.requestCampaign(ws_header, reqCampaign); results = ""; rs = response.result; } catch (Exception e) { results = e.Message; rs = null; } return(results); }
private string GetMultipleLeadsByListID(string in_list, ref Marketo_WS_2_0.ResultGetMultipleLeads rs) { Marketo_WS_2_0.SuccessGetMultipleLeads response = new Marketo_WS_2_0.SuccessGetMultipleLeads(); 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.MktowsContextHeaderInfo ws_context = new Marketo_WS_2_0.MktowsContextHeaderInfo(); ws_context = null; 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.ParamsGetMultipleLeads ws_leads = new Marketo_WS_2_0.ParamsGetMultipleLeads(); Marketo_WS_2_0.LeadKeySelector lks = new Marketo_WS_2_0.LeadKeySelector(); lks.keyType = Marketo_WS_2_0.LeadKeyRef.IDNUM; lks.keyValues = in_list.Split(','); ws_leads.leadSelector = lks; ws_leads.batchSize = 10; ws_leads.batchSizeSpecified = true; try { response = client.getMultipleLeads(ws_header, ws_leads); results = ""; rs = response.result; } catch (Exception e) { results = e.Message; rs = null; } return(results); }