我正在工作的PayPal支付系统,我想发送2个值在自定义字段。为此,我使用了urlencode(json_encode())功能。这是一个没有urlencoding的例子。
$customData = array();
$customData['invoiceID'] = $invoiceID;
$customData['username'] = urlencode($_GET['username']);
$p->add_field('custom', urlencode(json_encode($customData)));产出如下:
%7B%22invoiceID%22%3A108674%2C%22username%22%3A%22Just%2Btesting%22%7D当and解码和when解码时所期望的输出:
{"invoiceID":108674,"username":"Just testing"}但它给了我这个在解码和this解码之后:
{"invoiceID":108674,"username":"Just testing"}解决此问题的方法是再次对用户名本身进行urldecode。但是,为什么我需要双倍的urldecode才能得到我只运行了一次这个函数的值呢?
发布于 2015-03-04 14:55:51
似乎您要对数据应用两次urlencode(),所以需要应用两次urldecode()或删除其中的一次。
发布于 2015-03-04 14:57:08
我认为“自定义”字段用于识别另一端的请求,对吗?因此,该字段是供您使用的,而不是paypal。我觉得对它进行编码是个好主意。但是,如果您想让它在paypals后端生存,您可能需要使用base64encode和base64decode。
https://stackoverflow.com/questions/28857267
复制相似问题