IOS:自动更新的In App Purchase服务器到服务器的通知解析问题 [英] IOS:Auto renewable In App Purchase server to server notification parsing issue

查看:42
本文介绍了IOS:自动更新的In App Purchase服务器到服务器的通知解析问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法解析应用商店自动更新的购买通知.我只是要获取notification_type,但无法从服务器通知中解析其他文件.我的php代码:

I am unable to parse app store auto renewable purchase notification.I am only to get notification_type, but other fileds i am unable parse from server notification. my php code:

<?php

$input =json_decode(file_get_contents('php://input'), true);

$responseBody = $input['unified_receipt']['latest_receipt_info'][0]->original_transaction_id;
$notification_type = $input['notification_type'];

$sql="INSERT INTO testAppServerNotification (notification_type,notification) VALUES('$notification_type','$responseBody')";
$result=$conn->query($sql);
if($result){
   echo "success";
 }else{
     error_log("fail" . $conn->error);
 }
?>

推荐答案

json_decode()中的布尔值定义应将json对象解码为关联数组而不是对象.因此,您错误地输入了 orignal_transaction_id .

The boolean in json_decode() defines that json objects should be decoded as associative arrays instead of objects. Hence you access the orignal_transaction_id wrong.

您必须这样做:

$responseBody = $input['unified_receipt']['latest_receipt_info'][0]["original_transaction_id"];

这样,您应该可以解析通知.

This way, you should be able to parse the notification.

如果您想了解有关服务器通知结构的更多信息,请参见文档来自Apple.

If you want to learn more about the structure of server notifications, here is the documentation from Apple.

这篇关于IOS:自动更新的In App Purchase服务器到服务器的通知解析问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆