支付宝身份认证初始化服务40004未知的错误码
生活随笔
收集整理的這篇文章主要介紹了
支付宝身份认证初始化服务40004未知的错误码
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
?
下面是支付寶官方給出的示例:
?
$aop = new AopClient (); $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do'; $aop->appId = 'your app_id'; $aop->rsaPrivateKey = '請(qǐng)?zhí)顚戦_發(fā)者私鑰去頭去尾去回車,一行字符串'; $aop->alipayrsaPublicKey='請(qǐng)?zhí)顚懼Ц秾毠€,一行字符串'; $aop->apiVersion = '1.0'; $aop->signType = 'RSA2'; $aop->postCharset='GBK'; $aop->format='json'; $request = new AlipayUserCertifyOpenInitializeRequest (); $request->setBizContent("{" . "\"outer_order_no\":\"ZGYD201809132323000001234\"," . "\"biz_code\":\"FACE\"," . "\"identity_param\":\"{\\\"identity_type\\\":\\\"CERT_INFO\\\",\\\"cert_type\\\":\\\"IDENTITY_CARD\\\",\\\"cert_name\\\":\\\"收委\\\",\\\"cert_no\\\":\\\"260104197909275964\\\"}\"," . "\"merchant_config\":\"{\\\"return_url\\\":\\\"xxx\\\"}\"," . "\"face_contrast_picture\":\"xydasf==\"" . " }"); $result = $aop->execute ( $request); $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response"; $resultCode = $result->$responseNode->code; if(!empty($resultCode)&&$resultCode == 10000){ echo "成功"; } else { echo "失敗"; }會(huì)出現(xiàn)報(bào)錯(cuò):
?
這個(gè)是因?yàn)槿绻苯映瓕懥斯俜降陌噶?#xff0c;會(huì)在$request->setBizContent()添加參數(shù)時(shí),字符串拼接有誤,要對(duì)進(jìn)行修改
$data['cert_name']="收委";$data['cert_no']="260104197909275964";$data['outer_order_no']="ZGYD201809132323000001234";$aop = new AopClient ();$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';$aop->appId =C('appId');$aop->rsaPrivateKey = C('rsaPrivateKey');$aop->alipayrsaPublicKey=C('alipayrsaPublicKey');$aop->apiVersion = '1.0';$aop->signType = 'RSA2';$aop->postCharset='UTF-8';$aop->format='json';$request = new AlipayUserCertifyOpenInitializeRequest ();$request->setBizContent("{" ."\"outer_order_no\":\"".$data['outer_order_no']."\"," ."\"biz_code\":\"FACE\"," ."\"identity_param\":"."{\"identity_type\":\"CERT_INFO\",\"cert_type\":\"IDENTITY_CARD\",\"cert_name\":\"".$data['cert_name']."\",\"cert_no\":\"".$data['cert_no']."\"}"."," ."\"merchant_config\":"."{\"return_url\":\"www.baidu.com\"}"." }");$result = $aop->execute ( $request); echo "<pre>";var_dump($result);$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";$resultCode = $result->$responseNode->code;if(!empty($resultCode)&&$resultCode == 10000){echo "成功";} else {echo "失敗";}因?yàn)閕dentity_param 與 merchant_config 參數(shù)是字符串? 但里面也是json,要?jiǎng)h除官方的一些”\“,并自己拼接。如此就能成功的完成初始化。
結(jié)果如下:
?
總結(jié)
以上是生活随笔為你收集整理的支付宝身份认证初始化服务40004未知的错误码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Cydia Tweak
- 下一篇: 文件上传漏洞(客户端绕过,MIMEtip