Skip to content

Get the list of your Swiks

JuniorFt edited this page Feb 8, 2017 · 1 revision

#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 composer file.
require 'vendor/autoload.php';

use Swikly\SwiklyAPI;

$swkAPI = new SwiklyAPI('Your_Api_Key', 'YOUR_API_SECRET', 'developement');

// 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'];
}

<< Delete a Swik || Back to home || Make a Direct Swik >>

Clone this wiki locally