如何从C#Web应用程序中读取shopify数据

如何从C#Web应用程序中读取shopify数据

本文介绍了如何从C#Web应用程序中读取shopify数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I need to write an integration for Shopify. Shopify is an ecommerce platform which lets you create an ecommerce website.

So I have to write a c# code which pulls product information from a Shopify store.

any example would be appreciated





我尝试过:





What I have tried:

public string GetCustomers()
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            const string Url = "https://fd49a55f3afafdff141b8ab40809516b:[email protected]/admin/orders.json";
            var req = (HttpWebRequest)WebRequest.Create(Url);
            req.Method = "GET";
            req.ContentType = "application/json";
            req.Credentials = GetCredential(Url);
            req.PreAuthenticate = true;
            req.KeepAlive = false;

          //  req.ProtocolVersion = HttpVersion.Version10;
            using (var resp = (HttpWebResponse)req.GetResponse())
            {
                if (resp.StatusCode != HttpStatusCode.OK)
                {
                    string message = String.Format("Call failed. Received HTTP {0}", resp.StatusCode);
                    throw new ApplicationException(message);
                }

                var sr = new StreamReader(resp.GetResponseStream());
                return sr.ReadToEnd();
            }

        }
        private static CredentialCache GetCredential(string url)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
            var credentialCache = new CredentialCache();
            credentialCache.Add(new Uri(url), "Basic", new NetworkCredential("fd49a55f3afafd8ab40809516b", "ccb2e52e272c0c3f6bfa"));
            return credentialCache;
        }
    }

推荐答案


这篇关于如何从C#Web应用程序中读取shopify数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 09:18