Esempio n. 1
0
        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);
        }
Esempio n. 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);
        }