集成支付宝时:JSON.parse: unexpected character at line 1 column 1 of the JSON data
来源:互联网 发布:周琦cba数据 编辑:程序博客网 时间:2024/05/17 23:24
在集成支付宝时给IOS端返回JSON数据时遇到错误
JSON.parse: unexpected character at line 1 column 1 of the JSON data
支付宝在给请求信息进行签名:
if (str_replace('"','',$_POST['partner'])==$alipay_config['partner']&&str_replace('"','',$_POST['service'])==$alipay_config['service']) {
//将post接收到的数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串。
$data=createLinkstring($_POST);
//打印待签名字符串。工程目录下的log文件夹中的log.txt。
logResult($data);
//将待签名字符串使用私钥签名,且做urlencode. 注意:请求到支付宝只需要做一次urlencode.
$rsa_sign=urlencode(rsaSign($data, $alipay_config['private_key']));
//把签名得到的sign和签名类型sign_type拼接在待签名字符串后面。
$data = $data.'&sign='.'"'.$rsa_sign.'"'.'&sign_type='.'"'.$alipay_config['sign_type'].'"';
//返回给客户端,建议在客户端使用私钥对应的公钥做一次验签,保证不是他人传输。
echo $data;
}
else{
echo "不匹配或为空!";
logResult(createLinkstring($_POST));
}
IOS开发说要json数据,我就直接将$data 数据直接转化为json数据。支付宝处理过的字符串并不符合转化为JSON的数据要求,如果前端要求json数据不要对数据进行上面的处理。
- 集成支付宝时:JSON.parse: unexpected character at line 1 column 1 of the JSON data
- 集成支付宝时:JSON.parse: unexpected character at line 1 column 1 of the JSON data
- 关于SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data错误的解决
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data情况在easyui 的datagrid
- SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON火狐
- firefox报错 关于 JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
- JSON.parse: unexpected character
- Failed to parse json Unexpected token '\u0000' at 1:1
- JSON.parse: unexpected character的排查
- js报错:JSON.parse: unexpected character
- JSON.parse(str)报错Unexpected token t in JSON at position 1
- tomcat 启动出错 Parse Fatal Error at line 1 column 1:Premature end of file
- JSON ajax SyntaxError: JSON.parse: unexpected character异常
- .MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1
- 解析json Expected BEGIN_ARRAY but was NUMBER at line 1 column 5
- Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 4171 异常的解决方法
- Parse Fatal Error at line 1 column 7: The processing instruction target matching "[xX][mM][lL]" is not allowed.
- JSON parse 错误: unexpected token at分析和解决
- 线程的2种实现方式
- 单键索引还是组合索引
- java.lang.OutOfMemoryError: PermGen space 解决办法
- codeblocks配置GTK+
- 需要“jquery”ScriptResourceMapping。请添加一个名为 jquery (区分大小写)的 ScriptResourceMapping"解决方案
- 集成支付宝时:JSON.parse: unexpected character at line 1 column 1 of the JSON data
- 生成JSON数据--Gson(谷歌)方法
- Robot Framework自动化测试-切换浏览器窗口
- vmWare station安装cent os
- 数据库设计第三范式---一二三范式介绍
- eclipse导出项目时报错:problems were encountered during export
- AndroidStudio将变量值显示为十六进制
- linux 安装 apache,php,mysql
- [Python 实战]