Accessing the API via Guzzle Example - SibLiant/pws-schedule GitHub Wiki

As of now the calendar has a basic javascript web token controller that will allow any registered user to authenticate against a url that returns a web token. this token can then be used to post JSON directly into the database. The idea was to allow a client coder to write some of their own PHP to get and format their schedule / calendar data and post that to an account for display. Below is a working example.

Some initial setup

Create a new directory that will serve a basic web app and cd into it

mkdir my_test_app; cd my_test_app

Create a composer.json file and add the following text:

{
    "require": {
        "guzzlehttp/guzzle": "^6.1",
        "raveren/kint": "^1.0"
    }
}

composer install

The following is a basic class that uses Guzzle to access the API via a javascript web token to make a post with JSON data. Drop index.php in the root of my_test_app Let me know if you find any issues.

index.php

Adjust the above code by adding your own user / pass for authentication. I brought up a web server via the PHP built-in server as follows:

php -S localhost:8001 -t /var/www/my_test_app

The main app was running in the same manner on port 8000.