Skip to content

Repository files navigation

XGen SDK PHP

Official PHP SDK of the XGen API.


API Documentation : https://thomas-15.gitbook.io/generator/

Requirements

Installation

You can install the library via Composer. Run the following command:

composer require gmulti/xgen

To use the library, use Composer's autoload:

require_once__DIR__. '/vendor/autoload.php';

Example

Usage with data sample

<?phprequire_once__DIR__ . '/vendor/autoload.php';
useXGen\Client;
useXGen\XGen;
try {
$xgen = newXGen();
$xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-1.json');
$xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-2.json');
$xgen->addSourceFromFile(__DIR__ . '/vendor/gmulti/xgen/data/source.json');
$client = newClient('API_KEY');
$result = $client->getResource('generate')->postGenerateWithXGen($xgen);
var_dump($result);
// array (size=1)// 'text' => string 'Dans le cadre de la 2ème journée, Angers SCO accueille Olympique Lyonnais' (length=75)
} catch (\Exception$e) {
}

Load source from URL

<?phprequire_once__DIR__ . '/sdk/vendor/autoload.php';
useXGen\Client;
useXGen\XGen;
try {
$xgen = newXGen();
$xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-1.json');
$xgen->addContextFromFile(__DIR__ . '/vendor/gmulti/xgen/data/context-2.json');
$xgen->addSourceFromUrlJson('https://apigenerator.gmulti.now.sh/v1/example-data/source');
$client = newClient('API_KEY');
$text = $client->getResource('generate')->postGenerateWithXGen($xgen);
var_dump($result);
// array (size=1)// 'text' => string 'Dans le cadre de la 2ème journée, Angers SCO accueille Olympique Lyonnais' (length=75)
} catch (\Exception$e) {
}

About

xgen is guided and supported by Thomas Deneulin.

About

No description or website provided.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages