https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id
1.蘋果開發(fā)者后臺申請參數(shù)
https://appstoreconnect.apple.com/access/api/subs
這里生成一個(gè)密鑰
①復(fù)制Issuer ID缠俺,后面jwt參數(shù)會用到
②復(fù)制密鑰ID, 后面jwt參數(shù)會用到
③下載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', //應(yīng)用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"