I'm getting a callback, but correct message aren't sending with POST to .php.
What is wrong here?
Code:void PostRequest() { webrequest.EnqueuePost("http://www.mydomain.com/hwonline.php", "ServerIsOnline", (code, response) => GetCallback(code, response), this); } void GetCallback(int code, string response) { if (response == null || code != 200) { Puts($"Error: {code} - No Response"); return; } Puts("Response from hwonline.php : \n" + response); }
Sending a POST with message to .php
Discussion in 'Hurtworld Development' started by ★ OFFSET ★, Jan 12, 2017.
-
Try that ( my work code ):
filename: WEBrequest.cs
dir: oxide/plugins
Code:using Oxide.Core.Libraries.Covalence; using System.Collections.Generic;namespace Oxide.Plugins { [Info("WEBrequest", "HP61Rus", "1.1")] [Description("WEB request to site for get information. Test")] class WEBrequest : CovalencePlugin { [Command("request")] void PostRequest(IPlayer player, string command, string[] args) { var timeout = 200f; var headers = new Dictionary<string, string> { { "header", "value" } }; webrequest.EnqueuePost("http://donat.hurtworld-heaven.ru/q.php", "q=" + player.Id, (code, response) => GetCallback(code, response, player), this, headers, timeout); } void GetCallback(int code, string response, IPlayer player) { if (response == null || code != 200) { SendChatMessage(player, "<color=#FF0000>Site answer: </color>Error " + code); } else { SendChatMessage(player, "<color=#FF0000>Site answer: </color>: SteamID is " + response); } } void SendChatMessage(IPlayer player, string prefix, string msg = null) => player.Reply(msg == null ? prefix : "<color=#C4FF00>" + prefix + "</color>: " + msg); } }
If u see "Site answer: SteamID is 5676......" - that`s good.
that url ( http://donat.hurtworld-heaven.ru/q.php ) work always. for dev test.
Source of q.php
Code:<?=$_REQUEST["q"]?>
Sorry for my lang -
Thanks, this line:
Code:var headers = new Dictionary<string, string> { { "header", "value" } };
Close