Web

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,054
3,672
113
At your house.
github.com
Class:
Web

Class: https://github.com/Notulp/Fougerite/blob/master/Fougerite/Fougerite/Web.cs#L151

Examples:

Python:

import json
import clr
clr.AddReferenceByPartialName("Fougerite")
clr.AddReferenceByPartialName('System.Core')
import System
from System import Action
import Fougerite


class TestPlugin:

def webCallback(self, code, response):
if response != "Failed":
Fougerite.Logger.Log('[TestPlugin]: Response: ' + response)

def test(self):
MyExtraArguments = Plugin.CreateDict()
Web.CreateAsyncHTTPRequest('url', Action[int, str](self.webCallback), 'POST', json.dumps({'name':'test'}), MyExtraArguments, 'application/json')

def On_PluginInit(self):
self.test()
C#:

public class MyClass
{
[Newtonsoft.Json.JsonProperty]
public string Something
{
get;
set;
}

[Newtonsoft.Json.JsonProperty]
public int Something2
{
get;
set;
}
}

private void myCallback(int responsecode, string response)
{
if (response != "Failed")
{
Logger.Log("[TestPlugin]: Response: " + response);
}
}

public void Test()
{
MyClass something = new MyClass
{
Something = "something",
Something2 = 666
};
Web.GetInstance().CreateAsyncHTTPRequest("url", myCallback, "POST",
Newtonsoft.Json.JsonConvert.SerializeObject(something),
null, "application/json");
}