在Salesforce中向外公佈Service去建立Lead,並且用Asp.Net去呼叫此Service

Eric Sun發表於2014-11-14

1):在Salesforce中如何配置,向外公佈此Service,請看如下連結:

   http://www.shellblack.com/marketing/web-to-lead/ 

 

2):如何在Asp.Net中呼叫此Service去建立對應的Lead,請看如下程式碼:

            try
            {
                StringBuilder data = new StringBuilder();
                data.Append("oid=[youroid]");
                data.Append("&first_name=" + Server.UrlEncode(this.txtFirstName.Text));
                data.Append("&last_name=" + Server.UrlEncode(this.txtLastName.Text));
                data.Append("&email=" + Server.UrlEncode(this.txtEmail.Text));

                string url = "https://test.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8";
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                byte[] buffer = Encoding.UTF8.GetBytes(data.ToString());
                req.ContentLength = buffer.Length;
                using (Stream reqst = req.GetRequestStream())
                {
                    reqst.Write(buffer, 0, buffer.Length);
                }

                WebResponse response = req.GetResponse();
            }
            catch (Exception ex)
            {

            }

 

更多資訊也可以看如下連結: https://success.salesforce.com/ideaView?id=08730000000Y07QAAS 

 

3): http://www.chronoengine.com/faqs/61-cfv4/cfv4-tutorials/4112-how-can-i-send-form-data-to-salesforce.html 

 

相關文章