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"
网友评论