如何从C#Web应用程序中读取shopify数据 [英] How to read shopify data from C# web application

查看:333
本文介绍了如何从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:ccb2f6bfa@ausshirts99s34.myshopify.com/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;
        }
    }

推荐答案

无需编写自己的...这是一个积极开发的库您: GitHub - nozzlegear / ShopifySharp:ShopifySharp是一个C#和.NET库,可帮助开发人员轻松验证和管理Shopify商店。 [ ^ ]
No need to write your own... Here is an actively developed library for you: GitHub - nozzlegear/ShopifySharp: ShopifySharp is a C# and .NET library that helps developers easily authenticate with and manage Shopify stores.[^]


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆