UniversityPCCare / gsx-rest-php

PHP+MySQL implementation for Apple's GSX REST API
GNU General Public License v3.0
13 stars 6 forks source link

About

GSX-Rest is a PHP library that handles interactions with Apple's GSX REST API. It is a spiritual successor to filipp/gsxlib used to interact with Apple's GSX SOAP API, which was retired in late 2019.

Requirements

Installation

Upgrading to v2 REST API from v1

Apple made changes to the authentication API for v2 of their API. All authentication functions must go through /api, whereas all GSX API requests must go through /gsx/api. Additionally, there is a new Base URL.

If you are upgrading from v1, make the following changes to config.ini:

Configuration

This library can be configured either by setting values in a config.ini file or by passing in an associative array of options in a key => value format. For example, ["SOLD_TO" => "0123456789", ... ]

Basic configuration requires the following parameters:

Both the REST and the SOAP API require the following parameters:

The REST API requires the following parameters:

The SOAP API is deprecated and will be removed from this library. ~~Until Apple completely replaces the SOAP API, this library will implement all legacy SOAP functions as well. The SOAP API requires the following parameters~~:

Usage

After setting up config\config.ini:

<?php

require_once("../src/GSXHandler.php");

$gsx = new UPCC\GSXHandler($gsxUserEmail, $gsxShipTo);
$productDetails = $gsx->ProductDetails($serial);
echo $productDetails->device->configDescription;
> iPhone XS Max

Implemented Endpoints

All REST API endpoints are implemented in at least a basic capacity, meaning each endpoint has at least one corresponding function that takes an array as input and returns the response from the REST API, or NULL on no/invalid response. This basic function does no error checking or data validation, so it is assumed that the array passed to it is in a format that the REST API will accept, and that the values are valid. The array should be formatted such that, when passed through json_encode, it will result in a JSON Request Body formatted according to that endpoint's documentation in eServiceCentral.
Endpoints that accept GET requests instead of POST will not accept a JSON body, but instead will accept whatever query parameters the endpoint would expect. Some POST endpoints accept query parameters in addition to a JSON request body.

Endpoints with helper functions

The following endpoints have additional functions that help shape the request body. Some of the more complex endpoints (such as Consignment Validation Requests) have an associated helper class that will help you build a valid request body.

Repair

Diagnostics

Consignment

Content

Other

GSX Client Certificate and Configuration

You will need to work with the GSX Web Support team to obtain the following:

Follow the initial setup guide in Apple's eServiceCentral to get started.

GSX account with "Web Services" privilege enabled

You (or anyone else with admin access to MyAccess) will need to provision at least one account in MyAccess to have the "Web Services" privilege for GSX.