Wrapper class for the XML REST based TourCMS Marketplace API
コード例 #1
0
ファイル: TestApp.cs プロジェクト: TourCMS/tourcms-dotnet
        static void Main(string[] args)
        {
            #region TestApp Settings
                //
                // Tour Operators:
                // Set channelId and privateKey, leave marketplaceId as 0
                //
                // Partners (Affiliates, Agents etc):
                // Set marketplaceId and privateKey, leave channelId as 0
                // optionally set channelId to return just products from
                // that connection
                //
                // Both:
                // Optionally set a queryString to filter results
                // http://www.tourcms.com/support/api/mp/tour_search.php
                //

                    int channelId = Properties.Settings.Default.channelId;
                    int marketplaceId = Properties.Settings.Default.marketplaceId;
                    string privateKey = Properties.Settings.Default.privateKey;

                    //string queryString = "lat=56.82127&long=-6.09139&k=walking&per_page=3";
                    string queryString = "";
                //
                //
            #endregion

            // Check settings
            if( ( channelId == 0 && marketplaceId == 0 ) || privateKey == "" )
            {
                Console.WriteLine("Warning: You need to enter your API settings for this test app to work!");
            }

            // Create a new TourCMS object
            marketplaceWrapper myTourCMS = new marketplaceWrapper(marketplaceId, privateKey);

            // Query the TourCMS API
            XmlDocument doc = myTourCMS.SearchTours(queryString, channelId);

            // Check the status, will be OK if there's no problem
            string status = doc.GetElementsByTagName("error")[0].InnerText;
            if ( status == "OK" )
            {
                // Display Tour list
                XmlNodeList tourList = doc.GetElementsByTagName("tour");
                foreach ( XmlNode tour in tourList )
                {
                    string tourName = tour.SelectSingleNode("tour_name").InnerText;
                    Console.WriteLine(tourName);
                }
            } else {
                Console.WriteLine("Error: " + status);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // API Settings

                // Set your Marketplace ID
                // For Suppliers this will be 0
                // For Partners this can be found in the API settings page
                int marketplaceId = 0;

                // Set the Channel ID
                // For Suppliers this can be found in the API settings page
                // For Partners this will be 0
                int channelId = 0;

                // Set your API priate Key, find this in the API settings page
                string privateKey = "";

            // End API Settings

            // Create a new TourCMS object
            marketplaceWrapper myTourCMS = new marketplaceWrapper(marketplaceId, privateKey);

            // Call the API
            XmlDocument doc = myTourCMS.ApiRateLimitStatus(channelId);

            // Get the status from the XML, will be "OK" unless there's a problem
            string status = doc.GetElementsByTagName("error")[0].InnerText;

            if (status == "OK")
            {
                // Display API hits before the limit is reached
                string limit = doc.GetElementsByTagName("remaining_hits")[0].InnerText;
                Console.WriteLine("Remaining hits: " + limit);
            }
            else
            {
                Console.WriteLine("Error: " + status);
                Console.WriteLine("http://www.tourcms.com/support/api/mp/error_messages.php");
            }
        }