如何使用php验证Apple IAP收据?
发布时间:2020-12-13 17:41:58 所属栏目:PHP教程 来源:网络整理
导读:我正在使用php为iOS应用程序编写服务器. 我想通过访问Apple的appstore服务器来查看收据. 根据苹果的帮助文件.我必须向苹果的服务器发送一个帖子请求. http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/V
我正在使用php为iOS应用程序编写服务器.
我想通过访问Apple的appstore服务器来查看收据. 根据苹果的帮助文件.我必须向苹果的服务器发送一个帖子请求. http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/VerifyingStoreReceipts/VerifyingStoreReceipts.html#//apple_ref/doc/uid/TP40008267-CH104-SW1 我怎么能用php做到这一点,非常感谢! 任何人都可以举个例子吗? 解决方法<?php $applesharedsecret = "applesecretfromyourdevaccount"; $receiptbytes = "......applereceipt......."; $appleurl = "https://buy.itunes.apple.com/verifyReceipt"; // for production // use https://sandbox.itunes.apple.com/verifyReceipt for testing with sandbox receipt $request = json_encode(array("receipt-data" => $receiptbytes,"password"=>$applesharedsecret)); $ch = curl_init($appleurl); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$request); $jsonresult = curl_exec($ch); curl_close($ch); var_dump($jsonresult); // see the details of the receipt. ?> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |