Git Product home page Git Product logo

appstore-connect-api's Introduction

appstore connect api

unoffical sdk for appstore connect api. currently partially

see detail

install

composer require yunchuang/appstore-connect-api

example

use MingYuanYun\AppStore\Client;

$config = [
    'iss' => 'xx-xx-xx-xx-xxx',
    'kid' => 'xx',
    'secret' => '/path/to/private.p8'
];

$client = new Client($config);

// get jwt auth token, expired after 20 minutes later
$token = $client->getToken();

// set request auth header
$headers = [
	'Authorization' => 'Bearer ' . $token,
];
$client->setHeaders($headers);


// query devices
$queryParams = [
   'filter[platform]' => 'IOS',
   'filter[status]' => 'ENABLED',
   'filter[udid]' => '9be78daa0dbc12f3a95442caa164f36ab0b1ba47',
   'limit' => 1
];
$devices = $client->api('device')->all($queryParams);


// add device
$deviceName = 'test';
$platform = 'IOS';
$deviceUdid = '9be78daa0dbc12f3a95442caa164f36ab0b1ba47';
$result = $client->api('device')->register($deviceName, $platform, $deviceUdid);


// query bundleId
$params = [
   'fields[bundleIds]' => 'identifier',
   'filter[identifier]' => 'com.xx.xxx'
];
$result = $client->api('bundleId')->all($params);


// register bundleId
$name = 'test';
$platform = 'IOS';
$bundleId = 'com.xx.test';
$result = $client->api('bundleId')->register($name, $platform, $bundleId);


// delete bundleId
$id = 'xx';
$result = $client->api('bundleId')->drop($id);


// query capabilities of the bundleId
$bid = 'xx';
$params = [
   'fields[bundleIdCapabilities]' => 'capabilityType'
];
$result = $client->api('bundleId')->query($bid);


// add capability for the bundleId
$bid = 'xx';
$capability = 'PUSH_NOTIFICATIONS';
$result = $client->api('bundleIdCapabilities')->enable($bid, $capability);

// query profile
$params = [
   'filter[id]' => 'xx',
   'fields[profiles]' => 'bundleId,createdDate,expirationDate,name,profileState,profileType,uuid,profileContent'
];
$result = $client->api('profiles')->query($params);

// create profile for the bundleId
$bId = 'xx';
$name = 'mdev3';
$profileType = 'IOS_APP_DEVELOPMENT';
$devices = [
    'xx1', 'xx2', 'xx3'
];
$certificates = [
    'xx1'
];
$result = $client->api('profiles')->create($name, $bId, $profileType, $devices, $certificates);

remark

  • the profile content is base64 encoded, so you should base64 decode firstly, and then save as xxx.mobileprovision.

appstore-connect-api's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appstore-connect-api's Issues

openssl issue in JWT.php

Hello!
I have exception, when connecting to API.
#message: "openssl加密失败"
PHP Warning: openssl_sign(): supplied key param cannot be coerced into a private key in Utils/JWT.php on line 48
I fix it with this code:

    /**
     * @param $data
     *
     * @return string
     * @throws RuntimeException
     */
    protected function sign($data): string
    {
        $pkey = openssl_pkey_get_private("file://".$this->secret); // absolute path to key
        if ($pkey) {
            if ( !openssl_sign($data, $signature, $pkey, OPENSSL_ALGO_SHA256)) {
                throw new RuntimeException('openssl cannot sign');
            } else {
                return static::fromDER($signature, 64);
            }
        } else {
            throw new RuntimeException(openssl_error_string());
        }
    }

curl problem

HTTPS needs to skip SSL validation
after composer , vendor/php-curl-class/php-curl-class/src/Curl/Curl.php need to set curl
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
Otherwise, false is prompted on request
Remember to update~

profiles create problem

$certificates = [
    'xx1'
];
$result = $client->api('profiles')->create($name, $bId, $profileType, $devices, $certificates);

what does xx1 mean? The error message returned by my run is as follows.

{"errors":[{"id":"xxxxx","status":"409","code":"ENTITY_ERROR","title":"There is a problem with the request entity","detail":"There is no App ID with ID 'com.xxx.xxxx' on this team."}]}

关于新帐号调用返回403的说明

近期收到反馈,5月后新创建的帐号使用此库时会报403错误,具体错误如下:

array(1) {
["errors"] => array(1) {
[0] => array(4) {
["status"] => string(3) "403"
["code"] => string(9) "FORBIDDEN"
["title"] => string(18) "Access Unavailable"
["detail"] => string(227) "You currently don't have access to this resource. To resolve this issue, the Account Holder must agree to the latest Program License Agreement in their account on the Apple Developer website. https://developer.apple.com/account"
}
}
}

针对此问题进行过以下排查:
1、5月之前的帐号可正常调用
2、使用postman之类的工具调用app store connect api,也会报上述错误
3、苹果开发者后台并未见待同意的协议
4、苹果开发者后台可正常操作描述文件等功能

初步怀疑是app store connect api的BUG,非本库所能解决。

一个建议是直接联系客服反馈。
一个无理由的猜测:下一次有协议需要同意时可能就会恢复正常。

客服反馈地址:
https://developer.apple.com/contact/#!/topic/select

官方论坛有人反馈,但苹果开发人员一般不会回复,所以还是直接联系客服更有效。
https://forums.developer.apple.com/thread/132819

在此期间,可了解类似工具 fastlane,此工具并非基于api实现,应该不会出现上述问题。
本人并无实际使用经验,仅供参考。

如有解决方案,欢迎回复,谢谢!

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.