.NET is a free, cross-platform, open source developer platform released by Microsoft. NET you can create different types of applications. Within.net, C# is the most extensive and convenient development language.

Many users useful.NET package EasyGBS interface document requirements, this article we through the C# language to EasyGBS interface document. .net encapsulation.

Development tool: Microsoft Visual Studio 2010

Developing voice: C#

Create a new class library project

2, encapsulates the interface class library EasyGBSAPIClass, below mainly shows four interfaces 2.1 Login/API /1/login

public static string Login( string username, string password)
        {
            username = "easygbs";
            password = "EasyGBS@2020";
            string Url = "http://" + IP + ":" + port + "/api1/login";
            /ring username = this.txtUSER.Text;
            password = Md5.GetMd5(password);
            string str = "username=" + username + "&" + "password=" + password;
            try
            {
                string OutString = HTTP.SendGet(Url, str);
                return OutString;
            }
            catch(Exception ex)
            { return ex.ToString(); }
            return "Error";
        }
Copy the code

2.2 Querying the GB Device List API1 / Devicest

public static string GetDeviceList(int start, int limit, string q,string sort,string order,bool online)
        {
            string Url = "http://" + IP + ":" + port + "/api/v1/device/list";
            string str = "start=" + start + "&" + "limit=" + limit + "&" + "q" + q+"&"+"sort"+sort+"&"+"order"+order+"&"+"online"+online;
            try
            {
                string OutString = HTTP.SendGet(Url, str);
                return OutString;
            }
            catch (Exception ex)
            { return ex.ToString(); }
            return "Error";
        }
Copy the code

2.3 Querying the GB Device Channel list/API /v1/ Device /info

public static string GetDeviceChannelList(string serial, string q, int start, int limit, bool online, string channel_type, string dir_serial, string sort, string order)
        {
            string Url = "http://" + IP + ":" + port + "/api/v1/device/info";
            string str = "serial=" + serial + "&" + "q=" + "" + "&" + "start=" + start + "&" + "limit=" + limit + "&" + "online=" + online + "&" + "channel_type=" + channel_type + "&" + "dir_serial=" + dir_serial + "&" + "sort=" + sort+"&"+"order="+order;

            try
            {
                string OutString = HTTP.SendGet(Url, str);
                return OutString;
            }
            catch (Exception ex)
            { return ex.ToString(); }
            return "Error";
        }
Copy the code

Start/API /v1/stream/start

public static string StreamStart(string serial,string code)
        {
            string Url = "http://" + IP + ":" + port + "/api/v1/stream/start";
            string str = "serial=" + serial + "&" + "code=" + code;
            try
            {
                string OutString = HTTP.SendGet(Url, str);
                return OutString;
            }
            catch (Exception ex)
            { return ex.ToString(); }
            return "Error";
        }
Copy the code

3. Compile and generate DLLS