A quick start with C#
|
2017-08-29, 02:02
(This post was last modified: 2017-08-29 12:22 by Adorable.)
Post: #1
|
|||||||
|
|||||||
A quick start with C#
Using [TC]s new API inside C# Applications:
NOTE: Json.NET Library needed for converting from JSON -> .NET Code: class tcApi Obtaining Json.NET I recommend to anyone coding C# to use Visual Studio (A cross platform IDE), its just a matter of executing a command in the NuGeT Package manager console to obtain the library: Install-Package Newtonsoft.Json You do not need to download, drag and drop or link with the compiler. the program does it for you! Usage Add the classes "tcApi" and "Actions" to your project Make new instance of the class tcApi Use the method "getData" and pass in a string from the Action class, a deserialized dynamic object will be returned. Code: tcApi api = new tcApi(); NOTE: I covered the most important end points, rest will be added soon. Always refer to the documentation for the exact key value pairs property names as they are case sensitive, it is also important to surround your code with try {} and catch {} to avoid possible errors / crashes (eg: a mispelled username). |
|||||||
|
|||||||
2017-08-29, 07:27
Post: #2
|
|||||||
|
|||||||
RE: A quick start with C#
Not like I understand any of this, but it looks nice! Good work
|
|||||||
|
|||||||
2017-08-29, 11:39
(This post was last modified: 2017-08-29 11:40 by Pete.)
Post: #3
|
|||||||
|
|||||||
RE: A quick start with C#
For a fetching function, like the examples already in the docs, that function should do all of the query building.
All of the necessary data to run the request should be passed in to your main tcApi class. In your example you end up building the query strings in your helper class code, outside of the fetching function. The examples in the docs take in a very basic object which contains all of the necessary data to make the request, for example the config in the JS example: Code: var key = 'YOUR_KEY'; Your example should do the same so that the user of your function does not need to build query strings in order to make requests for data. If you'd like to have a go at making your main request function as fully featured as the PHP and JS examples in the docs, I can add it to that. |
|||||||
|
|||||||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)
Powered By MyBB, © 2002-2024 MyBB Group