這里根據(jù)看雪的文章 http://bbs.pediy.com/showthread.php?t=168303 ,
簡(jiǎn)單的用c#代碼模擬iTunes賬號(hào)的登陸(只考慮成功的情況),并獲取賬號(hào)里的信息,關(guān)于解析plist的庫(kù)現(xiàn)已有多個(gè)庫(kù)可用,
采用的是iphone-plist-net,地址在:http://code.google.com/p/iphone-plist-net/ 上。
模擬登陸最重要的是post 什么數(shù)據(jù)到 哪個(gè)url上,
通過(guò)跟蹤,這里是主要的數(shù)據(jù)
url地址:p3-buy.itunes.apple.com
post的數(shù)據(jù)為:
(Request-Line):GET /WebObjects/MZFinance.woa/wa/authenticate?appleId=xxx&password=xxx&attempt=1&machineName=&why=purchase&guid=4AEF365B.CF847F94.08E11EF5.FDD88C5B.09DA8172.65FAFEFB.6A193139&Pod=3&PRH=3 HTTP/1.1
Cache-Control:no-cache
Referer:http://itunes.apple.com/cn/
Accept-Language:zh-cn, zh;q=0.75, en-us;q=0.50, en;q=0.25
X-Apple-Tz:28800
X-Apple-Store-Front:143465-19,12
Host:p3-buy.itunes.apple.com
Connection:Close
post后返回的是plist格式的字符,里面包含了用戶的信息。
C#簡(jiǎn)單的代碼如下:
string strInfo = GetiTunesData("https://p3-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate?appleId=asdfasdf@asdf.co&password=qweqweqwe&attempt=1&machineName=&why=purchase&guid=4AEF365B.CF847F94.08E11EF5.FDD88C5B.09DA8172.65FAFEFB.6A193139&Pod=3&PRH=3");
Stream s = new MemoryStream(Encoding.UTF8.GetBytes(strInfo));
PListRoot root = PListRoot.Load(s);
PListDict dic = (PListDict)root.Root;
PListDict accountInfo = (PListDict)dic["accountInfo"];
PListDict address = (PListDict)accountInfo["address"];
string firstName = ((PListString)address["firstName"]).Value;
string lastName = ((PListString)address["lastName"]).Value;
Stream s = new MemoryStream(Encoding.UTF8.GetBytes(strInfo));
PListRoot root = PListRoot.Load(s);
PListDict dic = (PListDict)root.Root;
PListDict accountInfo = (PListDict)dic["accountInfo"];
PListDict address = (PListDict)accountInfo["address"];
string firstName = ((PListString)address["firstName"]).Value;
string lastName = ((PListString)address["lastName"]).Value;
這里可以知道,plist的很多字段,這里字段以后用來(lái)購(gòu)買(mǎi)軟件。