Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use User API?
#1
I am curious how to use the User API.

The first question is what is the URL of the User API. Is it /api/user.php ?

I try to test the functionality with GET and POST request, but the response is the same: 

Code:
{"section":"INV","request":"INV","response":"ERROR","message":"Invalid user api query!"}

The GET request is: 

Code:
https://example.com/hashtopolis/api/user.php?section=test&request=connection

which I refer to the documentation at: https://github.com/s3inlc/hashtopolis/bl...er-api.pdf

The POST request is similar, which I call it via PHP:

Code:
<?php
header('Content-Type: text/plain');

$data = array(
"section" => "test",
"request" => "connection"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://example.com/hashtopolis/api/user.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Possible attack hole: Man In The Middle
$response = curl_exec($ch);

var_dump($response);
?>

Identical response via POST. So what did I miss?
Reply
#2
The request data should be sent via POST and being in json format, so the header should be set accordingly (not necessary, but to be correct) and the data needs to be encoded with json_encode() before sending.
The automatic CI tests done on the API should help you if in doubt: https://github.com/s3inlc/hashtopolis/bl...ss.php#L65
Reply
#3
It works. Thanks for the tip!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)