Raised This Month: $ Target: $400
 0% 

amxx+php


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mikka
Member
Join Date: Dec 2018
Old 12-20-2018 , 12:04   amxx+php
Reply With Quote #1

Hello guys, how can I send data to a web server from this code and how to receive this data from it?



#include <amxmodx>
#include <amxmisc>
#include <sockets>

#define SITE "/index.php/2011/09/12/info-po-smierci/6"
#define HOST "darkgl.pl"

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "DarkGL"

new g_Socket;

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say /test","test")
}

public test(id){
new iError,szSendBuffer[512]

g_Socket = socket_open(HOST, 80, SOCKET_TCP, iError)

switch (iError)
{
case 1:
{
log_amx("Unable to create socket.")
return ;
}
case 2:
{
log_amx("Unable to connect to hostname.")
return ;
}
case 3:
{
log_amx("Unable to connect to the HTTP port.")
return ;
}
}

format(szSendBuffer, charsmax(szSendBuffer), "GET %s^nHost:%s^r^n^r^n", SITE, HOST)
socket_send(g_Socket, szSendBuffer, charsmax(szSendBuffer))

set_task(1.0, "socketAnswer", .flags = "b")
}

public socketAnswer(){
if (socket_change(g_Socket)) {
new szData[1024]

socket_recv(g_Socket, szData, charsmax(szData) )

log_amx(szData);

socket_close(g_Socket);

remove_task( 0 );
}
}

Last edited by Mikka; 12-20-2018 at 12:20.
Mikka is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode