Client library to consume the 42 Intranet's API

Overview

ft-client

Latest Stable Version Latest Unstable Version License Total Downloads PHP Version Require Unit tests

Client library to consume the 42 Intranet's API

Installation

composer require mehdibo/ft-client

Usage examples

Using the Authorization Code grant

include 'vendor/autoload.php';

$client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials(
    'CLIENT_ID',
    'CLIENT_SECRET',
    'REDIRECT_URI'
);

$client->fetchTokenFromAuthCode($_GET['code']);
$user = $client->get("/me");

Using the Client Credentials grant

include 'vendor/autoload.php';

$client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials(
    'CLIENT_ID',
    'CLIENT_SECRET',
    'REDIRECT_URI'
);

// This is not necessary, if no token was fetched it will automatically fetch one using the Client Credentials grant
$client->fetchTokenFromClientCredentials();

$cute = $client->get("/users/norminet");

Enumerating pages

This client comes with a method to easily enumerate pages of a paginated API endpoint.

include 'vendor/autoload.php';

$client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials(
    'CLIENT_ID',
    'CLIENT_SECRET',
    'REDIRECT_URI'
);

$users = $client->enumerate("/users", [
    'sort' => '-id',
]);

try {
    foreach ($users as $user) {
        echo $user['login'] . PHP_EOL;
    }
} catch (\Mehdibo\FortyTwo\Client\Exception\EnumerationRateLimited $e) {
    echo "Rate limited, retry in " . $e->retryAfter . " seconds\n";
    echo "Stopped at page " . $e->reachedPage . "\n";
}
You might also like...
A simple Object Oriented PHP Client for Termii SMS API

Termii Client A simple Object Oriented PHP Client for Termii SMS API. Uses Termii API. Requirements PHP = 7.2 Guzzlehttp ~6|~7 Installation Via Compo

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

php 8 client for the lemon.markets api

lemon.markets php client This repository contains a php 8+ compatible client for the https://lemon.markets API. The documentation of the API can be fo

PHP client for Microsoft Azure Face API.

Microsoft Azure Face API PHP client A PHP library that utilizes Azure Face REST API. Requirements PHP = 7.4 Installation composer require darmen/php-

Google PHP API Client Services

Google PHP API Client Services

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP
A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP. Including adding reviews to a store's products. It is used to import and export reviews through the API. This is the official package built and developed by A2Reviews, Inc.

PHP Client for the GoFlink API

GoFlink PHP API Client This project is an unofficial library to communicate with the GoFlink API from your PHP project. Documentation about the API is

A PHP client for the official Kizeo Forms API V3+. 📌

Kizeo Forms API V3+ - PHP This is a Swagger generated doc for Kizeo REST API 3. You can find additionnal documentation here : Online documentation. Th

⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC. This project is a work-in-progress. Code and docume

Releases(v1.0.1)
Owner
Mehdi Bounya
Mehdi Bounya
Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

Google APIs 8.4k Dec 30, 2022
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Sergey Bykov 63 Feb 14, 2022
PHP client library for the DynamicPDF Cloud API.

PHP Client (php-client) The PHP Client (php-client) project uses the DynamicPDF Cloud API's PHP client library to create, merge, split, form fill, sta

DynamicPDF Cloud API 0 Nov 29, 2021
API Client library for PHP

ChronoSheetsAPI ChronoSheets is a flexible timesheet solution for small to medium businesses, it is free for small teams of up to 3 and there are iOS

Lachlan P 0 May 23, 2022
DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Kévin Dunglas 25 Jul 27, 2022
Nexmo REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Client Library for PHP Support Notice This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintena

Nexmo 75 Sep 23, 2022
API client for ThePay - payment gate API

This is the official highly compatible public package of The Pay SDK which interacts with The Pay's REST API. To get started see examples below.

ThePay.cz s.r.o. 3 Oct 27, 2022
Code Quiz MonoRepo (API, API Client, App)

Code Quiz Welcome to the Code Quiz Open Source project from How To Code Well. This is an Open Source project that includes an API and an App for the d

How To Code Well 2 Nov 20, 2022
oursms.app client library that allows you to send SMS

Oursms laravel client https://oursms.app client library that allows you to send SMS Installation Install oursms client with composer composer requir

Khalid Mohammad 11 Aug 27, 2022
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

KNP Labs 2k Jan 7, 2023