1
我做編碼數據提供給收匯覈銷地址的base64的職位要求如下(這是在C#):奇怪的狀態代碼從蘋果收匯覈銷沙盒
var postSerializer = new JavaScriptSerializer();
byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(Receipt);
string returnValue = System.Convert.ToBase64String(toEncodeAsBytes);
var temp = new Dictionary<string, string>();
temp.Add("receipt-data", returnValue);
string jsonReceipt = postSerializer.Serialize(temp);
request.Method = "POST";
request.ContentType = "application/json";
byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(jsonReceipt);
request.ContentLength = postBytes.Length;
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(postBytes, 0, postBytes.Length);
// Close the Stream object.
dataStream.Close();
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
我敢肯定的事情是在因爲我沒有收到來自蘋果收據驗證端點的任何例外 。響應我回來的全部是
{狀態:-42352}
我不能找出這個錯誤在任何地方表示。有人知道這是什麼意思,或者如果我的代碼中有錯誤?
它的工作原理,這很瘋狂...蘋果的64位編碼是不同於C#/ PHP的?確實是黑魔法。非常感謝! – 2011-06-15 18:29:19
是的,我不確定這是從我的應用程序將數據發送到我的PHP服務的方式,但是從應用程序發送base64編碼的字符串,而不是在服務中編碼它。 – adjwilli 2012-06-28 12:09:20