PHPackages                             weijiajia/saloonphp-apple-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. weijiajia/saloonphp-apple-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

weijiajia/saloonphp-apple-client
================================

A PHP client for Apple's APIs built with Saloon PHP HTTP client framework

21062PHP

Since Aug 6Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/jackchang1025/saloonphp-apple-client)[ Packagist](https://packagist.org/packages/weijiajia/saloonphp-apple-client)[ RSS](/packages/weijiajia-saloonphp-apple-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Saloonphp Apple Client
======================

[](#saloonphp-apple-client)

[中文文档](README.zh-CN.md) | English

A PHP client for Apple's APIs built with [Saloon](https://github.com/saloonphp/saloon).

Features
--------

[](#features)

- Complete Apple API integration for various services:
    - Apple ID management
    - iCloud services
    - Account management
    - Authentication services
    - Buy/Purchase API
    - Report Problem services
- Built-in error handling for Apple-specific errors
- Cookie management for authenticated sessions
- HTTP proxy support
- Header synchronization
- Logging capabilities
- XML and Plist response parsing

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Saloon v3.0+

Installation
------------

[](#installation)

```
composer require weijiajia/saloonphp-apple-client
```

Usage
-----

[](#usage)

Advanced Usage
--------------

[](#advanced-usage)

### Cookie Management

[](#cookie-management)

```
use Weijiajia\SaloonphpCookiePlugin\Driver\FileCookieJar;

// Configure cookie jar
$cookieJar = new FileCookieJar('/path/to/cookies.json');
$connector->withCookieJar($cookieJar);
```

### Logging

[](#logging)

```
use Weijiajia\SaloonphpLogsPlugin\Driver\FileLogDriver;

// Configure logger
$logger = new FileLogDriver('/path/to/logs');
$connector->withLogger($logger);
```

### Header Synchronization

[](#header-synchronization)

```
use Weijiajia\SaloonphpHeaderSynchronizePlugin\Driver\ArrayStoreHeaderSynchronize;

// Configure header synchronization
$headerSynchronize = new ArrayStoreHeaderSynchronize();
$connector->withHeaderSynchronizeDriver($headerSynchronize);
```

### Proxy Queue

[](#proxy-queue)

```
use Weijiajia\SaloonphpHttpProxyPlugin\ProxySplQueue;
use Weijiajia\HttpProxyManager\Data\Proxy;

$proxySplQueue = new ProxySplQueue(roundRobinEnabled: true);
$proxySplQueue->enqueue(new Proxy(host:'127.0.0.1',port:'10809',username:"xxxx",password:'xxxx',url:'http://user-xxxx_password@127.0.0.1:10809'));
$connector->withProxyQueue($proxySplQueue);
```

```
use Weijiajia\SaloonphpHeaderSynchronizePlugin\Driver\ArrayStoreHeaderSynchronize;

// Configure header synchronization
$headerSynchronize = new ArrayStoreHeaderSynchronize();
$connector->withHeaderSynchronizeDriver($headerSynchronize);
```

### Basic Usage

[](#basic-usage)

```
// Import the necessary classes
use Weijiajia\SaloonphpAppleClient\Integrations\AppleId\AppleIdConnector;
use Weijiajia\SaloonphpLogsPlugin\Driver\FileLogDriver;
use Weijiajia\SaloonphpHeaderSynchronizePlugin\Driver\ArrayStoreHeaderSynchronize;

// Create a connector instance
$connector = new AppleIdConnector();

// Enable debugging
$connector->debug();

// Configure logging
$logger = new FileLogDriver('/path/to/logs');
$connector->withLogger($logger);

// Configure header synchronization
$connector->withHeaderSynchronizeDriver(new ArrayStoreHeaderSynchronize());

// Configure proxy if needed
$connector->withProxyQueue($proxySplQueue);

// Make requests
$response = $connector->send(new SomeAppleRequest());

// Handle responses
$data = $response->dto();
```

Available Integrations
----------------------

[](#available-integrations)

### Apple ID (AppleId)

[](#apple-id-appleid)

AppleId integration provides access to Apple ID management functionality.

```
use Weijiajia\SaloonphpAppleClient\Integrations\AppleId\AppleIdConnector;
use Weijiajia\SaloonphpAppleClient\Integrations\AppleId\Request\LoginRequest;
use Weijiajia\SaloonphpAppleClient\Integrations\AppleId\Request\SecurityCodeRequest;

// Create connector
$appleIdConnector = new AppleIdConnector();

// Login with Apple ID
$loginResponse = $appleIdConnector->send(new LoginRequest([
    'apple_id' => 'user@example.com',
    'password' => 'your_password'
]));

// Handle 2FA if needed
if ($loginResponse->requiresSecurityCode()) {
    $securityResponse = $appleIdConnector->send(new SecurityCodeRequest([
        'code' => '123456'
    ]));
}

// Access different resources
$accountResource = $appleIdConnector->getAccountResource();
$bootstrapResource = $appleIdConnector->getBootstrapResources();
$securityDevicesResource = $appleIdConnector->getSecurityDevicesResources();
$securityPhoneResource = $appleIdConnector->getSecurityPhoneResources();
$paymentResource = $appleIdConnector->getPaymentResources();
```

### iCloud Services (Icloud)

[](#icloud-services-icloud)

Access to iCloud services including family sharing management.

```
use Weijiajia\SaloonphpAppleClient\Integrations\SetupIcloud\SetupIcloudConnector;

// Create connector
$icloudConnector = new SetupIcloudConnector();

// Access family resources
$familyResources = $icloudConnector->getFamilyResources();

// Get family members
$familyMembers = $familyResources->getMembers();

// Access authentication resources
$authenticateResources = $icloudConnector->getAuthenticateResources();

// Setup resources
$setupResources = $icloudConnector->setupWResources();
```

### Purchase API (Buy)

[](#purchase-api-buy)

Interface with Apple's purchasing system.

```
use Weijiajia\SaloonphpAppleClient\Integrations\Buy\BuyConnector;

// Create connector
$buyConnector = new BuyConnector();

// Get resources
$resources = $buyConnector->getResources();

// Purchase an app
$purchaseResponse = $resources->purchase([
    'productId' => 'com.example.app',
    'price' => '0.99',
    'currency' => 'USD'
]);

// Get purchase history
$history = $resources->getPurchaseHistory();
```

### Report Problem (ReportProblem)

[](#report-problem-reportproblem)

Interface for reporting issues with purchased content.

```
use Weijiajia\SaloonphpAppleClient\Integrations\ReportProblem\ReportProblemConnector;

// Create connector
$reportConnector = new ReportProblemConnector();

// Get resources
$resources = $reportConnector->getResources();

// Report a problem with a purchase
$reportResponse = $resources->reportProblem([
    'purchaseId' => '1234567890',
    'issueType' => 'DOES_NOT_WORK',
    'comments' => 'The app crashes on startup'
]);
```

### Apple ID Registration for icloud.com

[](#apple-id-registration-for-icloudcom)

Complete flow for registering a new Apple ID with verification steps:

```
use Weijiajia\SaloonphpAppleClient\Integrations\AppleId\AppleIdConnector;
use Weijiajia\SaloonphpAppleClient\DataConstruct\AppleId;
use Weijiajia\SaloonphpHeaderSynchronizePlugin\Driver\ArrayStoreHeaderSynchronize;

// Create connector
$appleIdConnector = new AppleIdConnector();
$appleIdConnector->withHeaderSynchronizeDriver(new ArrayStoreHeaderSynchronize());

// Get widget account information
$response = $appleIdConnector->getAccountResource()->widgetAccount(
    widgetKey: 'd39ba9916b7251055b22c7f910e2ea796ee65e98b2ddecea8f5dde8d9d1a815d',
    referer: 'https://www.icloud.com/',
    appContext: 'icloud',
    lv: '0.3.16'
);

// Create verification info
$verificationInfo = VerificationInfo::from([
    'id' => '',
    'answer' => '',
]);

// Generate user information
$firstName = 'John';
$lastName = 'Doe';
$birthday = '1990-01-01';

// Create verification account
$verificationAccount = VerificationAccount::from([
    'name' => 'user@example.com',
    'password' => 'password123',
    'person' => [
        'name' => [
            'firstName' => $firstName,
            'lastName' => $lastName,
        ],
        'birthday' => $birthday,
        'primaryAddress' => [
            'country' => 'USA',
        ],
    ],
    'preferences' => [
        'preferredLanguage' => $response->getLocale(),
        'marketingPreferences' => [
            'appleNews' => false,
            'appleUpdates' => true,
            'iTunesUpdates' => true,
        ],
    ],
    'verificationInfo' => $verificationInfo,
]);

// Phone verification setup
$phoneNumberVerification = PhoneNumberVerification::from([
    'phoneNumber' => [
        'id' => 1,
        'number' => '5551234567',
        'countryCode' => 'US',
        'countryDialCode' => '1',
        'nonFTEU' => true,
    ],
    'mode' => 'sms',
]);

// Handle captcha
$captchaResponse = $appleIdConnector->getAccountResource()->captcha(
    $response->appleSessionId(),
    'd39ba9916b7251055b22c7f910e2ea796ee65e98b2ddecea8f5dde8d9d1a815d'
);

$captcha = Captcha::from([
    'id' => $captchaResponse->getId(),
    'token' => $captchaResponse->getToken(),
    'answer' => 'captcha-answer',
]);

// Create validation object
$validate = new Validate(
    $phoneNumberVerification,
    $verificationAccount,
    $captcha,
    false
);

// Verify Apple ID
$appleIdConnector->getAccountResource()->appleid(
    'user@example.com',
    $response->appleSessionId(),
    $response->getWidgetKey()
);

// Verify password
$appleIdConnector->getAccountResource()->password(
    'user@example.com',
    'password123',
    $response->appleSessionId(),
    $response->getWidgetKey()
);

// Submit validation
$validationResponse = $appleIdConnector->getAccountResource()->validate(
    validateDto: $validate,
    appleIdSessionId: $response->appleSessionId(),
    appleWidgetKey: $response->getWidgetKey()
);

// Send email verification code
$data = SendVerificationEmail::from([
    'account' => [
        'name' => 'user@example.com',
        'person' => [
            'name' => [
                'firstName' => $verificationAccount->person->name->firstName,
                'lastName' => $verificationAccount->person->name->lastName,
            ],
        ],
    ],
    'countryCode' => 'USA',
]);

$emailResponse = $appleIdConnector
    ->getAccountResource()
    ->sendVerificationEmail($data, $response->appleSessionId(), $response->getWidgetKey())
    ->dto();

// Validate email verification code
$verificationPut = VerificationEmail::from([
    'name' => 'user@example.com',
    'verificationInfo' => $validate->account->verificationInfo,
]);

$emailVerificationResponse = $appleIdConnector->getAccountResource()->verificationEmail(
    $verificationPut,
    $response->appleSessionId(),
    $response->getWidgetKey()
);

// Send phone verification code
$phoneCodeResponse = $appleIdConnector->getAccountResource()->sendVerificationPhone(
    $validate,
    $response->appleSessionId(),
    $response->getWidgetKey()
);

// Validate phone verification code
$phoneVerificationResponse = $appleIdConnector->getAccountResource()->verificationPhone(
    $validate,
    $response->appleSessionId(),
    $response->getWidgetKey()
);

// Complete account creation
$accountResponse = $appleIdConnector->getAccountResource()->account(
    validateDto: $validate,
    appleIdSessionId: $response->appleSessionId(),
    appleWidgetKey: $response->getWidgetKey()
);
```

### Error Handling

[](#error-handling)

The client includes specialized exception classes for various Apple API error scenarios:

```
use Weijiajia\SaloonphpAppleClient\Exception\UnauthorizedException;
use Weijiajia\SaloonphpAppleClient\Exception\AccountLockoutException;
use Weijiajia\SaloonphpAppleClient\Exception\VerificationCodeException;
use Weijiajia\SaloonphpAppleClient\Exception\AppleException;

try {
    $response = $connector->send($request);
} catch (UnauthorizedException $e) {
    // Handle authentication error
    echo "Authentication failed: " . $e->getMessage();
} catch (AccountLockoutException $e) {
    // Handle account lockout
    echo "Account locked: " . $e->getMessage();
} catch (VerificationCodeException $e) {
    // Handle verification code issues
    echo "Verification code error: " . $e->getMessage();
} catch (AppleException $e) {
    // Handle general Apple API errors
    echo "Apple API error: " . $e->getMessage();
}
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance43

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/636557533fde1107bb301eca908de1c17c9ea7073d5c9c0fbad725ccd0800bde?d=identicon)[jackchang1025](/maintainers/jackchang1025)

---

Top Contributors

[![422066139](https://avatars.githubusercontent.com/u/1780162?v=4)](https://github.com/422066139 "422066139 (96 commits)")

### Embed Badge

![Health badge](/badges/weijiajia-saloonphp-apple-client/health.svg)

```
[![Health](https://phpackages.com/badges/weijiajia-saloonphp-apple-client/health.svg)](https://phpackages.com/packages/weijiajia-saloonphp-apple-client)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M316](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
