I would like to use Paladins API to make a stats website but when I send a http request to create a session I get this error as answere from the API :
string(113) "{"ret_msg":"Exception while processing: Invalid date format","session_id":"","timestamp":"7\/6\/2022 3:49:56 PM"}"
The problem seems to be timestamp parameter. For sure I looked at
I've tried several timestamp but still stucked here. Note that I can successfully ping the API so thats not a server issue :
string(99) ""PaladinsAPI (ver 0.0.41.17634) [PATCH - 5.4] - Ping successful. Server Date:7\/6\/2022 4:05:18 PM""
Here is my code :
$ping = file_get_contents("https://api.paladins.com/paladinsapi.svc/pingJson");
var_dump($ping);
$createSession = file_get_contents("https://api.paladins.com/paladinsapi.svc/createsessionJson/myDevId/myDevPaswd/".strval(time()));
var_dump($createSession);
So here is my question : do someone already used this API and/or know what's wrong with my code ? or do someone know what to put as timestamp parameter to make my request work ?
CodePudding user response:
I looked at API documentation but no further information on what to put as timestamp
Are you sure about this? The example API call included on page 18 of this document shows explicitly how this is expected to be formatted, which is yyyyMMddHHmmss
.
Using the format identifiers on PHP: DateTime::format, you could do something along the lines of:
$api = file_get_contents("https://api.paladins.com/paladinsapi.svc/createsessionJson/myDevID/myDevPaswd/".date("YmdHis"));