Having troubles triggering a basic Get request and not entirely sure if I'm doing something wrong or the extension isn't yet compatible. I'm wanting to send a request to the URL and read the response.
These code snippets compile fine in the plugin and produce no error when being called - they simply don't output anything. I found a thread after searching and tried variations of it: http://oxidemod.org/threads/equivalent-to-webclient-downloadstring-in-c.6801/#post-66690
Using Google as an example - doesn't work on any specified URL. The code is being ported from a LUA plugin where it worked okay (via EnqueueGet).Code:WebRequests.GetWebrequest pWeb = new WebRequests.GetWebrequest("http://www.google.com", (code, response) => Puts("{0}, {1}", code, response), this); pWeb.Process();========var pWeb = new WebRequests.GetWebrequest("http://www.google.com", (code, response) => Puts("{0}: {1}", code, response), this); pWeb.Process();========WebRequests pWeb = new WebRequests(); pWeb.EnqueueGet("http://www.google.com", (code, response) => Puts("{0}, {1}", code, response), this);
Solved CSharp: WebRequest
Discussion in 'Rust Development' started by iDyn, Mar 9, 2015.
-
don't know will it work on oxide or not, but u can try:
Code:using System.Net; using System.IO; ... private static string GetRequest(string url) { WebResponse response = WebRequest.Create(url).GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadToEnd(); reader.Close(); response.Close(); return content; }void SomeFunction() { string req = GetRequest("http://oxidemod.org"); }
-
Wulf Community Admin
You'd need to use the Oxide webrequests API. See http://docs.oxidemod.org/#web-requests and https://github.com/OxideMod/Oxide/blob/master/Oxide.Core/Libraries/WebRequests.cs.
-
-
Wulf Community Admin
-
-
-
Wulf Community Admin
-
just a small example:
Code:Interface.GetMod().GetLibrary<WebRequests>("WebRequests").EnqueueGet("http://www.google.com", (code, response) => Puts("{0}, {1}", code, response), this);
-
Wulf Community Admin
-
Get that put into the CSharp examples! -
I did it, but the answer comes in the console all the code page. And in response to convey not all code pages such as "ok"