コード例 #1
0
        private static void RunSample(string username, string password, string accountId)
        {
            // Connect to the service
            ContentForShoppingService service = new ContentForShoppingService("Datafeed-Sample", accountId);

            service.setUserCredentials(username, password);

            // Retrieve the list of all existing accounts
            DatafeedFeed feed = service.QueryDatafeeds();

            // Display title and filename for each datafeed
            Console.WriteLine("Listing all datafeeds returned");
            foreach (DatafeedEntry m in feed.Entries)
            {
                Console.WriteLine("Datafeed: " + m.Title.Text + " (" + m.FeedFileName + ")");
            }

            // Create a new datafeed entry
            DatafeedEntry entry = new DatafeedEntry();

            entry.Title.Text        = "ABC Store Electronics products feed";
            entry.AttributeLanguage = "en";
            entry.ContentLanguage   = "en";
            entry.FeedFileName      = "electronics.txt";
            entry.TargetCountry     = "US";

            FileFormat format = new FileFormat();

            format.Format          = "dsv";
            format.Delimiter       = "pipe";
            format.Encoding        = "utf8";
            format.UseQuotedFields = "no";

            entry.FileFormat = format;

            // Add the datafeed
            Console.WriteLine("Inserting datafeed");
            DatafeedEntry inserted = service.InsertDatafeed(entry);

            // Update the datafeed we just inserted
            Console.WriteLine("Updating datafeed");
            inserted.Title.Text = "DEF Store Electronics products feed";
            DatafeedEntry updated = service.UpdateDatafeed(inserted);

            // Retrieve the new list of datafeeds
            feed = service.QueryDatafeeds();

            // Display title and filename for each datafeed
            Console.WriteLine("Listing all datafeed returned");
            foreach (DatafeedEntry m in feed.Entries)
            {
                Console.WriteLine("Datafeed: " + m.Title.Text + " (" + m.FeedFileName + ")");
            }

            // Delete the datafeed we inserted and updated
            Console.WriteLine("Deleting datafeed");
            service.DeleteDatafeed(updated);
        }