Wiki
Clone wikiphpsdkswikly / Get the list of your swiks
#Get the list of your swiks
Before looking at this make sure you understood the Initialization
It will be required for the Step 1.
1 - Get the list
<?php $result = $swkAPI->getListSwik();
You will have all the swiks that you create from the API.
The '$result' object will contain a status and if the status is 'ok' there will be the list of your swiks:
"status": "ok", "list": [ { "id": "SWIK_ID", "createdAt": "DD/MM/YYYY", "accepted": "0", // or 1 if accepted "acceptedAt": null, // if accepted the date have this format: "DD/MM/YYYY" "deleted": "0", // or 1 if deleted "deletedAt": null, // if deleted the date have this format: "DD/MM/YYYY" "currency": "EUR", "amount": "3500" // in cent }, ... ]
If you asked swiks from the Swikly website , they won't appear in that list.
2 - Handling the result
- If no error happened, a status 'ok' is returned.
- If there is an error with the Swikly API you can log it or do whatever you need.
<?php if ($result['status'] == 'ok') { echo "List of swik(s) = "; print_r($result['list']); } else { echo "Failed getting the swik list"; echo "Error = " . $result['message']; }
3 - Full code
<?php // 1. Load the SDK file. require 'YOUR/PATH/phpSdkSwikly.php'; $swkAPI = new \Swikly\SwiklyAPI('example_api_key', 'API_SECRET', 'development'); // Get the list of your swiks $result = $swkAPI->getListSwik(); // Print result of the operation if ($result['status'] == 'ok') { echo "List of swik(s) = "; print_r($result['list']); } else { echo "Failed getting the swik list"; echo "Error = " . $result['message']; }
Updated