美文网首页
苹果App Store Server API接口调试PHP

苹果App Store Server API接口调试PHP

作者: belm | 来源:发表于2022-11-04 17:43 被阅读0次

https://developer.apple.com/documentation/appstoreserverapi/creating_api_keys_to_use_with_the_app_store_server_api

https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id

1.苹果开发者后台申请参数
https://appstoreconnect.apple.com/access/api/subs
这里生成一个密钥
①复制Issuer ID,后面jwt参数会用到
②复制密钥ID, 后面jwt参数会用到
③下载P8格式密钥文件,注意只能下载一次,注意保存好,不用泄露

2.PHP引用jwt库

"firebase/php-jwt": "^5.2",

3.请求代码

//从苹果后台下载的密钥
$private_key = '-----BEGIN PRIVATE KEY-----
your secret key
-----END PRIVATE KEY-----';

$payload = [
    'iss' => '苹果后台的Issuer ID',
    'iat' => intval(time()),
    'exp' => intval(time() + 3600),
    'aud' => 'appstoreconnect-v1',  //固定值
    'bid' => 'xxxx', //应用bundle_id
];
$jwt_str = JWT::encode($payload, $private_key, 'ES256', '苹果后台的密钥ID')
curl -v -H 'Authorization: Bearer $jwt_str' "https://api.storekit.itunes.apple.com/inApps/v1/lookup/苹果transactionid"

相关文章

网友评论

      本文标题:苹果App Store Server API接口调试PHP

      本文链接:https://www.haomeiwen.com/subject/irlutdtx.html