{"id":15293899,"url":"https://github.com/cantie/app-store-connect-api-php","last_synced_at":"2025-04-13T13:31:21.667Z","repository":{"id":175816584,"uuid":"648581261","full_name":"cantie/app-store-connect-api-php","owner":"cantie","description":"A PHP client library for accessing Apple App Store Connect API","archived":false,"fork":false,"pushed_at":"2024-03-23T04:11:12.000Z","size":665,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-23T13:42:39.390Z","etag":null,"topics":["api","api-client","app-store","app-store-connect","apple","appstore","appstoreconnect","appstoreconnectapi","laravel","laravel-framework","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cantie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-02T09:56:57.000Z","updated_at":"2024-08-11T11:38:14.039Z","dependencies_parsed_at":"2024-08-11T11:51:37.375Z","dependency_job_id":null,"html_url":"https://github.com/cantie/app-store-connect-api-php","commit_stats":null,"previous_names":["cantie/app-store-connect-api-php"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantie%2Fapp-store-connect-api-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantie%2Fapp-store-connect-api-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantie%2Fapp-store-connect-api-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cantie%2Fapp-store-connect-api-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cantie","download_url":"https://codeload.github.com/cantie/app-store-connect-api-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248721026,"owners_count":21151031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","app-store","app-store-connect","apple","appstore","appstoreconnect","appstoreconnectapi","laravel","laravel-framework","php"],"created_at":"2024-09-30T16:53:36.267Z","updated_at":"2025-04-13T13:31:16.659Z","avatar_url":"https://github.com/cantie.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# App Store Connect APIs Client Library for PHP\n![GitHub Release](https://img.shields.io/github/v/release/cantie/app-store-connect-api)\n![Packagist Downloads](https://img.shields.io/packagist/dt/cantie/app-store-connect-api)\n![Packagist License](https://img.shields.io/packagist/l/cantie/app-store-connect-api)\n![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/cantie/app-store-connect-api/php)\n\n\n\nThis library enables the automation of actions you take in App Store Connect. Its client was modified from [Google API PHP Client](https://github.com/googleapis/google-api-php-client) and i just added some resources for App Store Connect APIs.\n\n\n## Installation ##\n\nThe preferred method is via [composer](https://getcomposer.org/). Follow the\n[installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have\ncomposer installed.\n\nOnce composer is installed, execute the following command in your project root to install this library:\n\n```sh\ncomposer require cantie/app-store-connect-api\n```\n## Examples ##\nSee the [`examples/`](examples) directory for examples of some APIs. You can\nview them in your browser by running the php built-in web server.\n\n```\n$ php -S localhost:8000 -t examples/\n```\n\nAnd then browsing to the host and port you specified\n(in the above example, `http://localhost:8000`).\n\n### Basic Example ###\n```php\nuse AppleClient;\nuse AppleService_AppStore;\nuse Cantie\\AppStoreConnect\\Services\\AppStore\\CustomerReviewResponseV1CreateRequest;\n\n$client = new AppleClient();\n$client-\u003esetApiKey(\"PATH_TO_API_KEY\");\n$client-\u003esetIssuerId($issuerId);\n$client-\u003esetKeyIdentifier($keyIdentifier);\n\n$appstore = new AppleService_AppStore($client);\n// Get apps by Bundle ID\n$results = $appstore-\u003eapps-\u003elistApps([\n    \"filter[bundleId]\" =\u003e \"YOUR_BUNDLE_ID\" // filter LIKE\n]);\n\n// Get all customer reviews for each app\nforeach ($results-\u003egetData() as $app) {\n    $appCustomerReviews = $appstore-\u003eapps-\u003elistAppsCustomerReviews($app-\u003egetId());\n    foreach ($appCustomerReviews as $appCustomerReview) {\n        // Print all reviewer's nickname\n        $appCustomerReview-\u003egetAttributes()-\u003egetReviewerNickName(), \"\u003cbr /\u003e \\n\";\n\n        // Get response for this review\n        $customerReviewResponseV1Response = $appstore-\u003ecustomerReviews-\u003egetCustomerReviewsResponse($appCustomerReview-\u003egetId());\n\n        // Create or update response for this review\n        $postBody = new CustomerReviewResponseV1CreateRequest([\n            'data' =\u003e [\n                'attributes' =\u003e [\n                    'responseBody' =\u003e \"YOUR_REPLY_TEXT_HERE\"\n                ],\n                'relationships' =\u003e [\n                    'review' =\u003e [\n                        'data' =\u003e [\n                            'id' =\u003e $appCustomerReview-\u003egetId()\n                        ]\n                    ]\n                ]\n            ]\n        ]);\n        $customerReviewResponseV1Response = $appstore-\u003ecustomerReviewResponses-\u003ecreateCustomerReviewResponses($postBody);\n\n        // Or just delete the response if existed\n        $appstore-\u003ecustomerReviewResponses-\u003edeleteCustomerReviewResponses($customerReviewResponseV1Response-\u003egetData()-\u003egetId());\n    }\n}\n```\n\n### Create new client ###\n```php\nuse AppleClient;\n\n$client = new AppleClient();\n$client-\u003esetApiKey(\"PATH_TO_API_KEY\");\n$client-\u003esetIssuerId($issuerId);\n$client-\u003esetKeyIdentifier($keyIdentifier);\n// Optional: create new JWT token. If skip this step, token are auto generated when first request are sent\n$client-\u003egenerateToken();\n```\n\n### Making a request ###\nFor almost all request except upload service, we use AppStore service to handle\n```php\nuse AppleService_AppStore;\n// All resources and their methods parameters are listed in src/Service/AppStore.php\n$appstore = new AppleService_AppStore($client);\n// Make request, for example we call request for an Apps's resources\n$appstore-\u003eapps-\u003elistAppsAppStoreVersions($APP_ID_HERE, $OPTIONAL_PARAMS);\n```\nFor detail, you can view in src/Services/AppStore/Resource/*\n\n### Aliases ###\nBasic classes are aliased for convenient use, see more at src/aliases.php\n\n```php\n$classMap = [\n    'Cantie\\\\AppStoreConnect\\\\Client' =\u003e 'AppleClient',\n    'Cantie\\\\AppStoreConnect\\\\Service' =\u003e 'AppleService',\n    'Cantie\\\\AppStoreConnect\\\\Services\\\\AppStore' =\u003e 'AppleService_AppStore',\n    'Cantie\\\\AppStoreConnect\\\\Services\\\\Upload' =\u003e 'AppleService_Upload'\n];\n```\n\n### Upload assets to App Store Connect ###\nIn this example we will upload one screenshot file to app screenshot set\n```php\n// Firstly, we get app screenshot set step by step, we can reduce steps by include[] parameters in query\nuse AppleService_Upload;\nuse Cantie\\AppStoreConnect\\Services\\AppStore\\AppScreenshotCreateRequest;\nuse Cantie\\AppStoreConnect\\Services\\AppStore\\AppScreenshotUpdateRequest;\n\n$appId = $app-\u003egetId(); // $app from previous example\n$appStoreVersions = $appstore-\u003eapps-\u003elistAppsAppStoreVersions($appId);\n// Get first app store version id;\n$appStoreVersionId = $appStoreVersions-\u003egetData()[0]-\u003egetId();\n// Get list localizations of this version\n$appStoreVersionLocalizations = $appstore-\u003eappStoreVersions-\u003elistAppStoreVersionsAppStoreVersionLocalizations($appStoreVersionId);\n// Get first localization id\n$appStoreVersionLocalizationId = $appStoreVersionLocalizations-\u003egetData()[0]-\u003egetId();\n// Get list app screenshot sets for this localization\n$appScreenshotSets = $appstore-\u003eappStoreVersionLocalizations-\u003elistAppStoreVersionLocalizationsAppScreenshotSets($appStoreVersionLocalizationId);\n// Get first set id\n$appScreenshotSetId = $appScreenshotSets-\u003egetData()[0]-\u003egetId();\n\n// Now, we make an asset reservation\n$fileName = \"YOUR_FILE_NAME\";\n$filePath = \"FULL_PATH_TO_YOUR_FILE\" . $fileName;\n$requestCreateAppScreenshot = new AppScreenshotCreateRequest([\n    'data' =\u003e [\n        'type' =\u003e 'appScreenshots',\n        'attributes' =\u003e [\n            'fileSize' =\u003e filesize($filePath),\n            'fileName' =\u003e $fileName\n        ],\n        'relationships' =\u003e [\n            'appScreenshotSet' =\u003e [\n                'data' =\u003e [\n                    'type' =\u003e 'appScreenshotSets',\n                    'id' =\u003e $appScreenshotSetId\n                ]\n            ]\n        ]\n    ]\n]);\n// Create new app screenshot\n$appScreenshot = $appstore-\u003eappScreenshots-\u003ecreateAppScreenshots($requestCreateAppScreenshot);\n$appScreenshotId = $appScreenshot-\u003egetData()-\u003egetId();\n// Follow instruction from UploadOperation[] return in $appScreenshot to upload part or whole asset file\n// We can upload parts of your asset concurrently\nforeach ($appScreenshot-\u003egetData()-\u003egetAttributes()-\u003egetUploadOperations() as $uploadOperation) {\n    $upload = new AppleService_Upload($client, $uploadOperation); // $client from above example\n    $ret = $upload-\u003euploadAssets-\u003eupload($uploadOperation, $filePath);\n}\n// Finally, commit the reservation\n$appScreenshotUpdateRequest = new AppScreenshotUpdateRequest([\n    'data' =\u003e [\n        'type' =\u003e 'appScreenshots',\n        'id' =\u003e $appScreenshotId,\n        'attributes' =\u003e [\n            'sourceFileChecksum' =\u003e md5_file($filePath),\n            'uploaded' =\u003e true\n        ]\n    ]\n]);\n$ret = $appstore-\u003eappScreenshots-\u003eupdateAppScreenshots($appScreenshotId, $appScreenshotUpdateRequest); \n```\n\n### Initialize classes ###\nAll object classes are extended from Model.php can be initialized by an array of attribute names and values, as previous example:\n```php\nuse Cantie\\AppStoreConnect\\Services\\AppStore\\AppScreenshotUpdateRequest;\n$appScreenshotUpdateRequest = new AppScreenshotUpdateRequest([\n    'data' =\u003e [\n        'type' =\u003e 'appScreenshots',\n        'id' =\u003e $appScreenshotId,\n        'attributes' =\u003e [\n            'sourceFileChecksum' =\u003e md5_file($filePath),\n            'uploaded' =\u003e true\n        ]\n    ]\n]);\n```\n\n### Caching ###\nJWT token are cached for 10 minutes and only be created if doesn't existed or has been expired. JWT token is not shared between clients. Each client has its own token as defined in src/Client.php\n```php\npublic function generateToken()\n{\n    $tokenGenerator = new Generate($this-\u003egetApiKey(), $this-\u003egetKeyIdentifier(), $this-\u003egetIssuerId());\n    $jwtToken = $tokenGenerator-\u003egenerateToken();\n    // cache for 10 minutes\n    $this-\u003ejwtToken = $jwtToken;\n    $this-\u003ejwtTokenExpTime = Carbon::now()-\u003eaddMinutes(10)-\u003etimestamp;\n    return $jwtToken;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcantie%2Fapp-store-connect-api-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcantie%2Fapp-store-connect-api-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcantie%2Fapp-store-connect-api-php/lists"}