cornacum Posted July 15, 2023 Share Posted July 15, 2023 Hi all I am pretty new to php and API, and would appreciate any help or at least if you can forward me in the right direction with this. I have a working php file and I need to request some data from API. The third part who is handling API, has sent me the following code... What I am looking for is a basic sample code to understand how to get the data. Any help is highly appreciated. { "info": { "_postman_id": "3699c117-da38-4c11-93fe-451bae0bf8e4", "name": "AClock", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "ListDevicesDB", "request": { "method": "GET", "header": [ { "key": "token", "type": "text", "value": "X1h36&YOoiKR" } ], "url": { "raw": "http://193.123.123.123:6600/iclock/ListDevicesDB", "protocol": "http", "host": [ "193", "123", "123", "123" ], "port": "6600", "path": [ "iclock", "ListDevicesDB" ], "query": [ { "key": "deviceSerial", "value": "BJ2C193661559", "disabled": true } ] }, "description": "it provides a list of all devices that connected to the server. it is sorted by the time each device connected to server last time.\r\nyou can pass the \"deviceSerial\" to find a specific device OR skip this parameter to list all devices." }, "response": [] }, Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted July 15, 2023 Solution Share Posted July 15, 2023 That describes the "ListDevicesDB" API you can call. 1. It uses the GET method. 2. You need to include a "token" header that includes some value. If the value is what you included in your post then that needs to change because this was (probably) supposed to be a secret value and you've now shared it with the whole internet. 3. The URL is as given there. It optionally supports a "deviceSerial" query string parameter, as the description indicates. 4. It doesn't describe what the return value is. So you need to get a basic API calling thing in place. You can use libraries for it, or you can write the API calls yourself using cURL. Your first step should be to understand more about making API calls through PHP. It's all the same everywhere - only differences being exactly what the API wants, and that's the information they gave you. Once you understand a little more about API calls, then you can deal with the PHP code to try to make them. It's pretty simple but you do need to know more about what this is all about to be effective at it. Quote Link to comment Share on other sites More sharing options...
cornacum Posted July 16, 2023 Author Share Posted July 16, 2023 Thank you for prompt response. I have just found that the postman platform provides code samples it self, which comes in very useful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.