Code Monkey home page Code Monkey logo

apple-gsx's Introduction

apple-gsx

A wrapper class written in PHP that simplifies communicating with Apple GSX Web Service API via SOAP.

Requirements

  • PHP 5.4.x
  • SOAP support
  • Signed certificate(s)
  • Whitelisted IP address

Usage

Include the class in your project.

function autoload($class) {
	require_once("{$class}.class.php");
}

spl_autoload_register('autoload');

The class has a constructer, so you have to instantiate it using parameters.

$gsx = new GSX('{REGION CODE}', '{ENVIRONMENT}', '{CERTIFICATE FILE}', '{CERTIFICATE PASSPHRASE}');

Now you can simply call $gsx->request('method', $data) where $data is an array containing the appropriate data for the method.

Examples

Authentication

Authentication creates a session ID that's needed for all other methods. The session ID is valid for 30 minutes, so you'll probably want to save it along with a timestamp in a browser session or database to prevent the user from getting a ATH.LOG.20 error.

$data = [
	'AuthenticateRequest' => [
		'userId' => '[email protected]',
		'languageCode' => 'en',
		'userTimeZone' => 'CEST',
		'serviceAccountNo' => '1000001',
	],
];

$request = $gsx->request('Authenticate', $data)->AuthenticateResponse;
echo json_encode($request);

The output (if successful) would look something like

{"userSessionId":"26US9Svslm6DzQpQRDLkdfM","operationId":"LnjrLfZfhK3GLM4TzwRKv"}

Warranty status

Want to know the warranty status of a device?

'WarrantyStatusRequest' => [
	$data = [
		'userSession' => [
			'userSessionId' => '26US9Svslm6DzQpQRDLkdfM',
		],
		'unitDetail' => [
			'serialNumber' => '70033CDFA4S',
			'shipTo' => '1000001',
		],
	],
];

$gsx->request('WarrantyStatus', $data)->WarrantyStatusResponse->warrantyDetailInfo->warrantyStatus;

Need to know if specific part(s) are covered with a certain CompTIA?

$parts[] = ['partNumber' => '661-02757', 'comptiaCode' => 'H03'];
$parts[] = ['partNumber' => '661-7109', 'comptiaCode' => 'L03'];

$data = [
	'WarrantyStatusRequest' => [
		'userSession' => [
			'userSessionId' => '26US9Svslm6DzQpQRDLkdfM',
		],
		'unitDetail' => [
			'serialNumber' => '70033CDFA4S',
			'partNumbers' => $parts,
			'shipTo' => '1000001',
		],
	],
];

$gsx->request('WarrantyStatus', $data);

For the remaining examples $data is an array containing the appropriate data for the API method.

Find my iPhone / Activation Lock status

To lookup Activation Lock status, simply grab the activationLockStatus key in the response.

$gsx->request('WarrantyStatus', $data)->WarrantyStatusResponse->warrantyDetailInfo->activationLockStatus;

IMEI to serial number

$gsx->request('FetchIOSActivationDetails', $data)->FetchIOSActivationDetailsResponse->activationDetailsInfo->serialNumber;

CompTIA codes

$gsx->request('ComptiaCodeLookup', $data)->ComptiaCodeLookupResponse->comptiaInfo;

GSX API docs

Integration Testing (GSXIT)

Acceptance Testing (GSXUT)

Production (GSX)

License

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

apple-gsx's People

Contributors

esbenbjerre avatar

Watchers

 avatar  avatar

Forkers

iparanoia99

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.