Quote:
Originally Posted by DJ Tsunami
HTTP
Retrieve an item
PHP Code:
#include <sourcemod> #include <ripext>
public void OnPluginStart() { HTTPRequest request = new HTTPRequest("https://jsonplaceholder.typicode.com/todos/1");
request.Get(OnTodoReceived); }
void OnTodoReceived(HTTPResponse response, any value) { if (response.Status != HTTPStatus_OK) { // Failed to retrieve todo return; }
// Indicate that the response contains a JSON object JSONObject todo = view_as<JSONObject>(response.Data);
char title[256]; todo.GetString("title", title, sizeof(title));
PrintToServer("Retrieved todo with title '%s'", title); }
|
This isn't working. it's not even sending the http request. The function OnTodoReceived is called but with a Null response. The HTTP request is not even reaching the server. The extension on the server is running.
edit: The (php-) api (using get paramters) is working. I was able to call it with the Steamworks extention as well. But I need the Json decoding on the response.