SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/01/2020, 09:38 PM   #1
markjonh
Little Clucker
 
Join Date: Dec 2013
Posts: 18
Reputation: 0
Default SOME WAY TO SEND A POST REQUEST

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
markjonh is offline   Reply With Quote
Old 03/01/2020, 12:34 AM   #2
Danbo7
Little Clucker
 
Join Date: Nov 2019
Posts: 21
Reputation: 0
Default Re: SOME WAY TO SEND A POST REQUEST

Just use GET instead - pm me if u need help with this
Danbo7 is offline   Reply With Quote
Old 03/01/2020, 02:49 AM   #3
CXdur
Big Clucker
 
CXdur's Avatar
 
Join Date: Jun 2014
Location: Norway
Posts: 57
Reputation: 6
Default Re: SOME WAY TO SEND A POST REQUEST

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];
....
}
CXdur is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does my welcome mails send from my server land in spam post? Frede Server Support 1 05/02/2013 02:13 PM
Bug on send request to OnPlayerConnect Swimor Scripting Help 5 29/12/2012 04:55 AM
Multiple post request data - HTTP function iToast Scripting Help 2 15/03/2012 02:39 AM
[REQUEST] United States Roleplay [REQUEST] GameMode 0.3C! Samo70 Help Archive 1 10/05/2011 03:41 PM
Best place to post this request... XG General 5 21/03/2011 08:05 PM


All times are GMT. The time now is 12:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.