Code:
/* Sublime AMXX Editor v2.2 */
#include <amxmodx>
// #include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>
#include <sockets>
#define PLUGIN "TEST"
#define VERSION "1.0"
#define AUTHOR "Ish Chhabra"
#define PLUGIN_HOST "pluginszone.000webhostapp.com"
#define PLUGIN_TOPIC "/query.php"
#define TASKID_WAITANSWER 1231213
new g_Socket;
new g_Data[1024];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("plugintest", "myplugintest");
// Add your code here...
}
public myplugintest()
{
new error
g_Socket = socket_open(PLUGIN_HOST, 80, SOCKET_TCP, error);
if(g_Socket)
{
new sendbuffer[512];
format(sendbuffer, charsmax(sendbuffer), "GET %s HTTP/1.1^nHost: %s^n^n", PLUGIN_TOPIC, PLUGIN_HOST);
socket_send(g_Socket, sendbuffer, charsmax(sendbuffer));
set_task(1.0, "task_waitanswer", TASKID_WAITANSWER, _, _, "a", 15);
}
else
{
switch(error)
{
case 1 : server_print("Error creating socket");
case 2 : server_print("Error resolving remote hostname");
case 3 : server_print("Error connecting socket");
}
}
}
public task_waitanswer(id)
{
if(socket_change(g_Socket))
{
socket_recv(g_Socket, g_Data, charsmax(g_Data));
server_print("%s", g_Data)
}
}
This is the updated code I'm using
This is what I get
PHP Code:
HTTP/1.1 200 OK
Date: Tue, 09 Jan 2018 08:44:14 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: awex
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Request-ID: 3974a9fe3b4ed6
__________________