【IOS】IAP (内置购买) 服务器端代码
来源:互联网 发布:2017免流源码 编辑:程序博客网 时间:2024/06/05 19:20
PHP 服务器端代码,
首先要确 php的 curl 和 SSL (open_ssl)这两个模块开启,可以在 php.ini 中去掉 这两个dll前面的分号。
<?php//服务器二次验证代码 function getReceiptData($receipt, $isSandbox = false) { if ($isSandbox) { $endpoint = 'https://sandbox.itunes.apple.com/verifyReceipt'; } else { $endpoint = 'https://buy.itunes.apple.com/verifyReceipt'; } $postData = json_encode( array('receipt-data' => $receipt) ); $ch = curl_init($endpoint); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); //这两行一定要加,不加会报SSL 错误 curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); $response = curl_exec($ch); $errno = curl_errno($ch); $errmsg = curl_error($ch); curl_close($ch); //判断时候出错,抛出异常 if ($errno != 0) { throw new Exception($errmsg, $errno); } $data = json_decode($response); //判断返回的数据是否是对象 if (!is_object($data)) { throw new Exception('Invalid response data'); } //判断购买时候成功 if (!isset($data->status) || $data->status != 0) { throw new Exception('Invalid receipt'); } //返回产品的信息 return array( 'quantity' => $data->receipt->quantity, 'product_id' => $data->receipt->product_id, 'transaction_id' => $data->receipt->transaction_id, 'purchase_date' => $data->receipt->purchase_date, 'app_item_id' => $data->receipt->app_item_id, 'bid' => $data->receipt->bid, 'bvrs' => $data->receipt->bvrs ); } //获取 App 发送过来的数据,设置时候是沙盒状态 $receipt = $_GET['data']; $isSandbox = true; //开始执行验证try { $info = getReceiptData($receipt, $isSandbox); // 通过product_id 来判断是下载哪个资源 switch($info['product_id']){case 'com.application.xxxxx.xxxx':Header("Location:xxxx.zip");break; } }//捕获异常catch(Exception $e) { echo 'Message: ' .$e->getMessage(); }?>
- 【IOS】IAP (内置购买) 服务器端代码
- 【IOS】IAP (内置购买) 服务器端代码
- 【IOS】IAP (内置购买) 服务器端代码
- IAP内置购买服务器端
- ios 内置付费 iap
- iOS iAP 支付与购买
- iOS IAP应用内置付费
- iOS IAP应用内购买汇总
- iOS应用内购买项目(IAP)
- iOS应用内置付费 IAP设置总结
- 苹果不允许 iOS 应用内置购买(IAP)使用第三方支付方式,那么跨平台的支付怎么解决这个问题?
- ios iap 购买总是提示继续的解决方案
- iOS IAP 一次支付,购买一种商品多次
- 为iOS应用/游戏内建购买项目(IAP)
- 【IOS】 In App Purchase 内置购买 总结
- IAP-应用内购买
- iOS应用内置付费 IAP Store Kit Guide翻译
- ios6下的程序内购买IAP http://www.raywenderlich.com/zh-hans/25155/ios-6-iap入门
- 如何在32位程序中突破地址空间限制使用超过4G的内存
- 如何查找Linux文件 存放在哪(地点) locate find whereis which 命令
- ServletConfig对象的应用
- MPLAB C 数据存储器不能创建大于256边界
- 在Spring框架下获取Bean的方式总结
- 【IOS】IAP (内置购买) 服务器端代码
- 关于BufferedReader /writer和FileDialog
- ASCII编码、GB2312编码、Unicode编码
- python socket上传文件的服务端和客户端实现
- 学习他人,成长自己,获取你想要的知识=====在清华听演讲
- Apk文件破解
- python socket向百度发送http长连接请求 并做搜索
- valgrind 介绍
- vi 快捷键