Paypal IPN发回VERIFIED,但带有前后号码 [英] Paypal IPN sends back VERIFIED but with numbers before and after

查看:82
本文介绍了Paypal IPN发回VERIFIED,但带有前后号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Paypal 文档说 :

PayPal发送回一个单词,如果 出现任何与PayPal或INVALID不一致的消息 原始发送的内容

PayPal sends a single word back, which is either VERIFIED if the message originated with PayPal or INVALID if there is any discrepancy with what was originally sent

但是,我从Paypal收到以下IPN通知(注意:我正在使用沙盒进行测试):

However, I get the following IPN notification from Paypal (NOTE:I'm using Sandbox for testing):

HTTP/1.1 200 OK
.... [removed headers for brevity]
Content-Type: text/html; charset=UTF-8

8
VERIFIED
0

验证之前和之后的数字8和0是什么?我的猜测8是已验证单词的长度,但这只是一个猜测.

What are the numbers 8 and 0 before and after VERIFIED? My guess 8 is length of the VERIFIED word but that's just a guess.

更新正如PayPal_Robert正确指出的,这是由于HTTP分块传输编码.来自维基百科页面:

update As PayPal_Robert correctly pointed out, this is because of HTTP chunked transfer encoding. From wikipedia page:

每个块的大小在块本身之前发送,这样 接收方可以告知接收数据的完成时间 块.数据传输以最后一个长度的块终止 零.

The size of each chunk is sent right before the chunk itself so that the receiver can tell when it has finished receiving data for that chunk. The data transfer is terminated by a final chunk of length zero.

推荐答案

这是由于分块的HTTP数据和常规的fsockopen()集成,包括在响应中.

This is because of chunked HTTP data and a regular fsockopen() integration including this in the response.

您可以应用trim()进行修整并专门查看INVALID/VERIFIED,或者从fsockopen()切换到cURL(假设您使用的是PHP).

You can either apply trim() to trim this and look at INVALID/VERIFIED specifically, or switch from fsockopen() to cURL (assuming you're using PHP).

就个人而言,我建议您使用像cURL这样的适当的HTTP库,而不是fsockopen(),因为它现在和将来都具有更大的灵活性.

Personally, I would advise you to use a proper HTTP library like cURL as opposed to fsockopen(), as it allows for greater flexibility, both now and in the future.

这篇关于Paypal IPN发回VERIFIED,但带有前后号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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