繁体   English   中英

Google Merchant产品Feed不接受我的Feed

[英]Google Merchant Product Feed not Accepting my Feed

我正在使用GData API将产品导入到我的商家Feed中。 代码如下:

List<ProductEntry> newEntries = new List<ProductEntry>();
                    foreach (Product prod in ent.Products.Where(i => !i.IsDeleted && i.IsDisplayed && i.Price > 0))
                    {
                        newEntries.Add(prod.GetNewEntry());
                    }
                    string GoogleUsername = "nope@gmail.com";
                    string GooglePassword = "*****";
                    ContentForShoppingService service = new ContentForShoppingService("MY STORE");
                    service.setUserCredentials(GoogleUsername, GooglePassword);
                    service.AccountId = "*******";
                    service.ShowWarnings = true;
                    ProductFeed pf = service.InsertProducts(newEntries);
                    r.Write(pf.Entries.Count.ToString());

此代码返回给我1个条目,而不是应返回的400+,并且该1个条目为空,没有错误或警告信息。 我的商人中心破折号上没有任何显示。 关于这里可能发生什么的任何想法?

或-我如何获得正在发生的事情的更多详细信息?

完成链接上提到的操作后,您将获得

  • 客户编号

  • 客户秘密

我们将用于认证的那些。

 var credentials = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets() { 
                    ClientId = "yourclientid", 
                    ClientSecret = "yourclientsecret" },
                new string[] { ShoppingContentService.Scope.Content },
                "user",
                CancellationToken.None).Result;

  //make this a global variable or just make sure you pass it to InsertProductBatch or any function that needs to use it
  service = new ShoppingContentService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credentials,
            ApplicationName = "Your-app-name"
        });

现在是插入部分:

private async Task<List<Product>> InsertProductBatch(IEnumerable<Product> products, ulong merchantaccountid)
        {
            // Create a batch request.
            BatchRequest request = new BatchRequest(service);

            List<Product> responseproducts = new List<Product>();

            foreach (var p in products)
            {
                ProductsResource.InsertRequest insertRequest =
                    service.Products.Insert(p, merchantaccountid);
                request.Queue<Product>(
                         insertRequest,
                         (content, error, index, message) =>
                         {

                             responseproducts.Add(content);
                             //ResponseProducts.Add(content);

                             if (content != null)
                             {
                                 //product inserted successfully
                             }
                             AppendLine(String.Format("Product inserted with id {0}", ((Product)content).Id));

                             if (error != null)
                             {
                                 //there is an error you can access the error message though error.Message
                             }

                         });

            }

            await request.ExecuteAsync(CancellationToken.None);
            return responseproducts;
        }

仅此而已。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM