transactionReceipt 验证 json 应该是什么样子?

发布于 2024-09-08 19:47:04 字数 1693 浏览 3 评论 0原文

我正在尝试验证沙盒交易收据 https://sandbox.itunes.apple.com/verifyReceipt< /a> 使用 php 和 cURL。

到达我的服务器时的原始收据如下所示:

{ "signature" = "AksOP5dmXwg 9WjlcE7PwBEFZgcqBnIb0Uv2lSKebWJJpcOZQRL6ejYyv20MzPFDSgAj3GRGoJXWZpyJLAU8qZSQFYQeGljWKZd3XTJN4j1E7fqOQRBdIXSDRJr1phB/11xp smk6m ... dgcxRHuOMZ2tm8npLUm7argOSzQ=="; "purchase-info" = "ewoJIml0ZW0taWQiID0gIj ... jAiOwp9"; "pod" = "100"; "signing-status" = "0"; }

1。它应该有等号和分号吗?

将其包装在我使用的 cURL 中进行传输:

$receipt = json_encode(array("receipt-data" => base64_encode($transactionReceipt)));

给出:

{"receipt-data":"ewoJInNpZ25hdHVyZSIgPSAiQ ... <lots more of the same> ... XR1cyIgPSAiMCI7Cn0="} 

这会导致: 来自 Apple 的 {"status":-42023}

如果我使用:

$receipt = json_encode(array("receipt-data" => $transactionReceipt));

给出:

{"receipt-data":"{\n\t\"signature\" = \"AksOP5dmXwg 9WjlcE7PwBEFZgcqBnIb0Uv2lSKebWJJpcOZQRL6ejYyv20MzPFDSgAj3GRGoJXWZpyJLAU8qZSQFYQeGljWKZd3XTJN4j1E7fqOQRBdIXSDRJr1phB\/11xp smk6m ... dgcxRHuOMZ2tm8npLUm7argOSzQ==\";\n\t\"purchase-info\" = \"ewoJIml0ZW0taWQiID0gIjM3NTgyNzIyOCI7Cgkib3JpZ2luYWwtdHJhbnNhY3Rpb24taWQiID0gIjEwMDAwMDAwMDA1ODQyNDIiOwoJInB1cmNoYXNlLWRhdGUiID0gIj ... jAiOwp9\";\n\t\"pod\" = \"100\";\n\t\"signing-status\" = \"0\";\n}"}

我得到:{“status”:21002,“exception”:“java.lang.IllegalArgumentException:尝试读取不带引号的字符串时属性列表解析失败。找不到允许的字符。在行号:1 ,列:0。"}

2.谁能告诉我收据数据 json 应该是什么样子?

谢谢!

I'm trying to verify a sandbox transactionReceipt at https://sandbox.itunes.apple.com/verifyReceipt using php and cURL.

The original receipt when it arrives at my server looks like:

{ "signature" = "AksOP5dmXwg 9WjlcE7PwBEFZgcqBnIb0Uv2lSKebWJJpcOZQRL6ejYyv20MzPFDSgAj3GRGoJXWZpyJLAU8qZSQFYQeGljWKZd3XTJN4j1E7fqOQRBdIXSDRJr1phB/11xp smk6m ... dgcxRHuOMZ2tm8npLUm7argOSzQ=="; "purchase-info" = "ewoJIml0ZW0taWQiID0gIj ... jAiOwp9"; "pod" = "100"; "signing-status" = "0"; }

1. Should it have the equals and semicolons?

Wrapping this up for transmission in the cURL I use:

$receipt = json_encode(array("receipt-data" => base64_encode($transactionReceipt)));

which gives:

{"receipt-data":"ewoJInNpZ25hdHVyZSIgPSAiQ ... <lots more of the same> ... XR1cyIgPSAiMCI7Cn0="} 

This results in: {"status":-42023} from Apple

If I use:

$receipt = json_encode(array("receipt-data" => $transactionReceipt));

which gives:

{"receipt-data":"{\n\t\"signature\" = \"AksOP5dmXwg 9WjlcE7PwBEFZgcqBnIb0Uv2lSKebWJJpcOZQRL6ejYyv20MzPFDSgAj3GRGoJXWZpyJLAU8qZSQFYQeGljWKZd3XTJN4j1E7fqOQRBdIXSDRJr1phB\/11xp smk6m ... dgcxRHuOMZ2tm8npLUm7argOSzQ==\";\n\t\"purchase-info\" = \"ewoJIml0ZW0taWQiID0gIjM3NTgyNzIyOCI7Cgkib3JpZ2luYWwtdHJhbnNhY3Rpb24taWQiID0gIjEwMDAwMDAwMDA1ODQyNDIiOwoJInB1cmNoYXNlLWRhdGUiID0gIj ... jAiOwp9\";\n\t\"pod\" = \"100\";\n\t\"signing-status\" = \"0\";\n}"}

I get: {"status":21002, "exception":"java.lang.IllegalArgumentException: Property list parsing failed while attempting to read unquoted string. No allowable characters were found. At line number: 1, column: 0."}

2. Can anyone please tell me what the receipt-data json is supposed to look like?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若有似无的小暗淡 2024-09-15 19:47:04

我正用头撞墙,遇到同样的问题...检查一下:

$dataToPost = json_encode(array("receipt-data" => $receivedData));

其中 $receivedData 是收据 base64 编码。

然后:

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $dataToPost
    )
);

$context  = stream_context_create($opts);
$result = file_get_contents('https://sandbox.itunes.apple.com/verifyReceipt', false, $context);

它对我有用......尝试一下并让我知道!

I was banging with my head against the walls with the same problem... check this:

$dataToPost = json_encode(array("receipt-data" => $receivedData));

where $receivedData is the receipt base64 encoded.

Then:

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $dataToPost
    )
);

$context  = stream_context_create($opts);
$result = file_get_contents('https://sandbox.itunes.apple.com/verifyReceipt', false, $context);

It worked for me... give it a try and let me know!

您的好友蓝忘机已上羡 2024-09-15 19:47:04

这现在对我有用!我的最后一个错误是,在一系列测试和更改中,我实际上修改了收据数据文件。哎呀:(。我已经将收据缩进了 4 个字节,准备将帖子提交到 stackoverflow of all things。缩进收据使其无效,也许并不奇怪。

This is now working for me! My final bug was that I had, in series of tests and changes, actually modified the receipt data file. Ooops :(. I had indented the receipt by 4 bytes, in preparation for submitting a post to stackoverflow of all things. Indenting the receipt made it invalid, perhaps not surprisingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文