View Single Post
dordnung
Veteran Member
Join Date: Apr 2010
Old 04-05-2021 , 11:01   Re: [EXTENSION] System2 - Easy to use HTTP(S)/FTP Request API and useful system nativ
Reply With Quote #120

Quote:
Originally Posted by SpirT View Post
I have a php request like https://domain.com/index.php?content=somethinghere.
Then, the page will be blank with a simple number: 0 or 1.

I just didn't understand how to use this extension to get the body content and store it in a string...
For example like this:
PHP Code:
#include <sourcemod>
#include <system2>

public void OnPluginStart() {
    
System2HTTPRequest httpRequest = new System2HTTPRequest(HttpResponseCallback"https://domain.com/index.php?content=somethinghere");
    
httpRequest.GET();
    
delete httpRequest;
}

void HttpResponseCallback(bool success, const char[] errorSystem2HTTPRequest requestSystem2HTTPResponse responseHTTPRequestMethod method) {
    if (!
success) {
        
PrintToServer("Error on request: %s"error);
        return;
    }
    
    if (
response.StatusCode != 200) {
        
PrintToServer("Error: Found invalid status code %d"response.StatusCode);
        return;
    }
    
    
char content[10];
    
response.GetContent(contentsizeof(content));
   
    if (
StrEqual("0"content)) {
        
PrintToServer("Content is 0");
    } else if (
StrEqual("1"content)) {
        
PrintToServer("Content is 1");
    } else {
        
PrintToServer("Error: Found invalid content %s"content);
    }

Quote:
Originally Posted by CarOL View Post
the var: success in httprequest callback was always False
and the error message is "schannel: next InitializeSecurityContext failed: Unknown error (0x80092013)"
Should be fixed with 3.3.1

Quote:
Originally Posted by paviln1 View Post
PHP Code:
public int GetPlayerId() {
    
System2HTTPRequest httpRequest = new System2HTTPRequest(HttpResponseCallback"url");
    
httpRequest.SetHeader("Content-Type""application/json"); 
    
httpRequest.SetHeader("X-API-Key""1234");
}

public 
void HttpResponseCallback(bool success, const char[] errorSystem2HTTPRequest requestSystem2HTTPResponse responseHTTPRequestMethod method) {
    if (
success) {
        
char[] content = new char[response.ContentLength 1];
        
response.GetContent(contentresponse.ContentLength 1);

        
PrintToServer("Content of the response: %s"content);
    }

The response gives authentication failed. Could u maybe give an example how to do it?
I need a bit more information about your system to give you an answer here. You never send the request?

Quote:
Originally Posted by ESL_Ikarus View Post
[SM] Unable to load extension "system2.ext": bin/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /serverfiles/cstrike/addons/sourcemod/extensions/system2.ext.so)
Can you retry it with the newest version?
__________________

Last edited by dordnung; 04-05-2021 at 11:02.
dordnung is offline