Raised This Month: $ Target: $400
 0% 

SteamTools HTTPPOST


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Otokiru
Senior Member
Join Date: Apr 2012
Old 03-15-2015 , 09:54   SteamTools HTTPPOST
Reply With Quote #1

Hi, how can i return the http reponse string back to client?

My code:
Code:
public OnClientPostAdminCheck(client)
{
	new AdminId:admin = GetUserAdmin(client);
	if(GetAdminFlag(admin, Admin_Root))
	{
		decl String:steamID[256];
		GetClientAuthString(client, steamID, sizeof(steamID));
		SendRequest(steamID);
	}
}

SendRequest(String:steamID[]) {
    new HTTPRequestHandle:request = Steam_CreateHTTPRequest(HTTPMethod_POST, "http://somesite.com/checker.php");
    Steam_SetHTTPRequestGetOrPostParameter(request, "steamid", steamID);
    Steam_SendHTTPRequest(request, OnRequestComplete);
}

public OnRequestComplete(HTTPRequestHandle:request, bool:successful, HTTPStatusCode:status) {
    decl String:response[1024];
    Steam_GetHTTPResponseBodyData(request, response, sizeof(response));
    Steam_ReleaseHTTPRequest(request);
    //PrintToChat(client,"%s", response); <-- how can i print the response to the client???
}
Otokiru is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-15-2015 , 10:28   Re: SteamTools HTTPPOST
Reply With Quote #2

You can't arbitrarily pick the buffer size.
https://forums.alliedmods.net/showpo...2&postcount=21
__________________
asherkin is offline
Otokiru
Senior Member
Join Date: Apr 2012
Old 03-16-2015 , 09:57   Re: SteamTools HTTPPOST
Reply With Quote #3

erm so i can only send post but cant retrive the response?...
so is there any way i can retrieve text?
Otokiru is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-16-2015 , 10:19   Re: SteamTools HTTPPOST
Reply With Quote #4

Quote:
Originally Posted by Otokiru View Post
erm so i can only send post but cant retrive the response?...
so is there any way i can retrieve text?
Given what Asherkin linked, have you tried

PHP Code:
public OnRequestComplete(HTTPRequestHandle:requestbool:successfulHTTPStatusCode:status) {
    new 
size Steam_GetHTTPResponseBodySize();
    new 
String:response[size+1];
    
Steam_GetHTTPResponseBodyData(requestresponsesize+1);
    
Steam_ReleaseHTTPRequest(request);
    
PrintToChat(client,"%s"response);

__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 03-16-2015 at 10:29.
Powerlord is offline
Otokiru
Senior Member
Join Date: Apr 2012
Old 03-16-2015 , 10:22   Re: SteamTools HTTPPOST
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
Given what Asherkin linked, have you tried

PHP Code:
public OnRequestComplete(HTTPRequestHandle:requestbool:successfulHTTPStatusCode:status) {
    new 
size Steam_GetHTTPResponseBodySize();
    new 
String:response[size+1];
    
Steam_GetHTTPResponseBodyData(requestresponsesizeof(response));
    
Steam_ReleaseHTTPRequest(request);
    
PrintToChat(client,"%s"response);

i mean, how can i pass the client variable into OnRequestComplete method?
Otokiru is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-16-2015 , 11:24   Re: SteamTools HTTPPOST
Reply With Quote #6

Quote:
Originally Posted by Otokiru View Post
i mean, how can i pass the client variable into OnRequestComplete method?
Pass the userid via the contextData param.
__________________
asherkin is offline
Reply



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 04:43.


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