itunes礼品卡兑换【完整协议方案】
itunes礼品卡兑换协议方案
文章目录
- itunes礼品卡兑换协议方案
- 前言
- 一、登录itunes
- 二、兑换礼品卡
前言
本文章将完整编写apple礼品卡对话的流程。
 最后会附带C++的源代码。
一、登录itunes
登录itunes查看我另一篇文章itunes登录【完整协议方案】
登录后将拿到登录Cookies 和两个值 dsPersonId 、X-Apple-Store-Front
 dsPersonId 在响应的个人信息内容里
 X-Apple-Store-Front 对应响应头部的值 x-set-apple-store-front
二、兑换礼品卡
请求内容如下:
post https://buy.itunes.apple.com/commerce/redeemCodeSrv //设置请求头
Content-Type: application/x-apple-plist
User-Agent: iTunes/12.2.2 (Windows; Microsoft Windows 8 x64 Business Edition (Build 9200)) AppleWebKit/7605.1033.1002.2
Connection: keep-alive
X-Dsid:  + dsPersonId //dsPersonId 是上面得到的
X-Apple-Tz: 28801
X-Apple-Store-Front:  + x-set-apple-store-front //x-set-apple-store-front 是上面得到的
Accept-Language: zh-CN,zh;q=0.9,en;q=0
cookies:  + cookies //cookies 是上面得到的//设置请求体
<?xml version="1.0" encoding="UTF-8"?><plist version="1.0"><dict><key>attemptCount</key><real>0</real><key>code</key><string> + code + </string>  //code 需要兑换的卡<key>dsPersonId</key><integer> + dsPersonId + </integer>	//dsPersonId 是上面得到的<key>guid</key><string> + guid + </string> //guid 是上面生成的</dict></plist>
发包后响应 HTTP/1.1 200 则兑换成功
代码地址:
 itunes登录示例代码
