SOME WAY TO SEND A POST REQUEST
#1

Good community, I want to know how I can send data with the plugin a_http but using post because in the example of the wiki it is only with get
Reply
#2

Just use GET instead - pm me if u need help with this
Reply
#3

Quote:
Originally Posted by Danbo7
View Post
Just use GET instead - pm me if u need help with this
But why?

Quote:
Originally Posted by markjonh
View Post
Good community, I want to know how I can send data with the plugin a_http but using post because in the example of the wiki it is only with get
Code:
format(query, sizeof(query), "user=%s&email=%s&code=%s&hash=%s&token=thetoken", urlencode(PlayerName(playerid)), urlencode(email), urlencode(code), urlencode(verification_hash));

// Send the verification email
HTTP(playerid, HTTP_POST, "activations.example.com/include/verification_email.php", query, "HTTP_SendVerificationEmail");

forward HTTP_SendVerificationEmail(index, response_code, data[]);
public HTTP_SendVerificationEmail(index, response_code, data[])
{
	if (response_code == 200)
	{
		LOG_DEBUG_F("Success: %s", data);
	}
	else
	{
		LOG_DEBUG_F("Failed: %d", response_code);
	}
}
Example above for POST request. You just have to use the data parameter for POST requests.
Code:
native HTTP(index, type, url[], data[], callback[]);
GET Request below to show similarities.
Code:
// Trace the IP address
new ip_locate_q[60];
format(ip_locate_q, sizeof(ip_locate_q), "thegeoapi.com/csv/%s?fields=status,country,city", PlayerIP(playerid));
HTTP(playerid, HTTP_GET, ip_locate_q, "", "HTTP_OnIpTraced");

forward HTTP_OnIpTraced(index, response_code, data[]);
public HTTP_OnIpTraced(index, response_code, data[])
{
	new connect_msg[128],
		connect_msg_admin[128],
		connect_msg_panel[78];
....
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)