assoconnect/mapbox-token

PHP client for Mapbox Token API

dev-master 2022-10-30 20:00 UTC

This package is auto-updated.

Last update: 2024-03-29 03:32:47 UTC


README

PHP client for Mapbox Token API

Build Status Quality Gate Status

The following feature of the Mapbox API are implemented:

  • creation of a temporary token

Feel free to submit a PR or contact us if you need a missing feature.

The package uses Guzzle as an HTTP client.

Installation

This package can be install with composer

composer require assoconnect/mapbox-token

Usage

<?php

$guzzle = new GuzzleHttp\Client();
$client = new AssoConnect\MapboxToken\Client('YOUR MAPBOX USERNAME', 'YOUR MAPBOX TOKEN', $guzzle);

// Create a temporary token
$scopes = [
    'styles:read',
    'styles:tiles',
    'fonts:read',
    'datasets:read',
    'uploads:write',
    'uploads:read',
    'tokens:write',
];

$expires = new \DateTime('+ 1 hour');

$client->createTemporaryToken($scopes, $expires)->token; // New temporary Mapbox token