Skip to content

A PHP library which implements the functionality of the Craftnet API

License

Notifications You must be signed in to change notification settings

enupal/craftnet-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Craftnet API PHP Wrapper

A PHP library which implements the functionality of the Craftnet API. See the Craftnet API documentation for all available settings.

Installation

Add the library to your project via composer:

{
    "require": {
        "barrelstrength/craftnet-php": "{version}"
    }
}

Require the library in your project:

require __DIR__ . '/vendor/autoload.php';

Authentication

To authenticate with Craftnet set your username and apiKey values when instantiating a new CraftnetClient class.

use barrelstrength\craftnetphp\CraftnetClient;

$username = 'USERNAME';
$apiKey = 'API_KEY;

$client = new CraftnetClient($username, $apiKey);

Get all plugin licenses for the authenticated Craft ID user

$response = $client->pluginLicenses->get();

$pluginLicenses = $response->getBody()->getContents();

$results = json_decode($pluginLicenses);

Get a secondary page of plugin licenses for the authenticated Craft ID user

$response = $client->pluginLicenses->get([
  'page' => 2
]);

$pluginLicenses = $response->getBody()->getContents();

$results = json_decode($pluginLicenses);

Get a specific plugin license for the authenticated Craft ID user

<?php
$response = $client->pluginLicenses->get([
    'key' => 'P8GQRVQO5MK9Q673U0IJZ2I3'
]);

$pluginLicense = $response->getBody()->getContents();

$result = json_decode($pluginLicense)

Create a new license for a given Craft ID user

$response = $client->pluginLicenses->create([
  'edition' => 'standard',
  'plugin' => 'sprout-forms',
  'email' => 'sprout@barrelstrengthdesign.com'
]);

$pluginLicense = $response->getBody()->getContents();

$result = json_decode($pluginLicense)

About

A PHP library which implements the functionality of the Craftnet API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%