簡體   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