我正在使用一個簡單的PHP腳本來驗證Android訂單以解析客戶的下載。InApp計費在Web服務器上驗證訂單PHP
$receipt = $_GET['purchaseData'];
$billInfo = json_decode($receipt,true);
$signature = $_GET['dataSignature'];
$public_key_base64 = "xxxxxxxxxxxxxxxx";
$key = "-----BEGIN PUBLIC KEY-----\n".
chunk_split($public_key_base64, 64,"\n").
'-----END PUBLIC KEY-----';
$key = openssl_get_publickey($key);
$signature = base64_decode($signature);
//$result = openssl_verify($billInfo, $signature, $key);
$result = openssl_verify($receipt, $signature, $key);
if (0 === $result) {
echo "0";
} else if (1 !== $result) {
echo "1";
} else {
echo "Hello World!";
}
//added the var_dump($result); as asked by A-2-A
var_dump($result);
結果是0int(0)
我通過App做一個真正的訂單後,我出版了它,並試圖驗證順序時,我得到「0」的結果。
我嘗試直接HTTP訪問
https://domain.com/thankyou.php?purchaseData={"packageName":"com.example.app","orderId":"GPA.1234-5678-1234-98608","productId":"product","developerPayload":"mypurchasetoken","purchaseTime":1455346586453,"purchaseState":0,"developerPayload":"mypurchasetoken","purchaseToken":"ggedobflmccnemedgplmodhp...."}&dataSignature=gwmBf...
我保持第一的問題,因爲我的結果仍然是猜測。經過進一步調查,我認爲這是簽名不被谷歌發送的一個很好的乾淨的方式閱讀。
的signature=gwmBfgGudpG5iPp3L0OnepNlx
,而瀏覽器閱讀它作爲ƒ ~®v‘¹ˆúw
怎麼可能讓它能夠以正確的方式閱讀?
只是檢查'var_dump($ result);'顯示什麼。向我們展示 –
@ A-2-A它顯示「int(0)」現在網頁顯示「0 int(0)」 –
int(0)指的是我所知道的未知數,但它認爲它是未知數? –