Let's talk about php's integration with sesame credit, and php's integration with sesame credit
As the project needs to access sesame credit to authenticate users, open sesame credit official website (https:// B .zmxy.com.cn/index.htm) to view the official demo, see in the document
I instantly felt that this official demo was rubbish.
Note the following:
1. Generate a local key as prompted
2. Create an application in "Merchant management" and obtain the sesame credit Public Key through the key generated in the first step. This gives you the Encrypted Key.
Note: The Public Key provided by zhima credit can only be copied, but the copied format is incorrect. We need to manually process 64 lines, which is consistent with the key format generated by us, otherwise, encryption and decryption will not be performed;
3. The parameters to be passed can be obtained according to the document, but only one parameter is generated, and the data returned from the corresponding document needs to be processed;
Directly run the Code:
<? Php include ('/zmopclientphp'); include ('/Shanghai'); class TestAuthFreeze {// zhima credit gateway address public $ gatewayUrl = "https: // zmopenapizmxycomcn/openapido "; // merchant public key file // sesame public key file public $ privateKeyFile = "path/rsa_private_keypem"; public $ zmPublicKeyFile = "path/zima_public_keypem "; // data encoding format public $ charset = "UTF-8"; // appId public $ appId = "1000003 "; // generate the sign parameter required for mobile SDK integration. Line urlEncode public function generateSign ($ certNo, $ name, $ certType = 'Identity _ Card') {$ client = new ZmopClient ($ this-> gatewayUrl, $ this-> appId, $ this-> charset, $ this-> privateKeyFile, $ this-> zmPublicKeyFile); $ request = new ZhimaAuthInfoAuthorizeRequest (); $ request-> setScene ("test "); // set the authorization source channel to javasdk $ request-> setChannel ("javasdk "); // set the authorization type to 2 and identify it as certificate number. For details, see "business input parameter description identity_type in Section 4" $ request-> setIdentityTy Pe ("2"); // construct the Authorization Service input credential number, name, credential type; "identity_param" $ request-> setIdentityParam ("{\" certNo \ ": \" $ certNo \ ", \" certType \": \ "IDENTITY_CARD \", \ "name \": \ "$ name \"}"); // construct biz_params for business input parameters in section 4. $ request-> setBizParams ("{\" auth_code \": \ "m_javasdk \"} "); $ params = $ client-> generateEncryptedParamWithUrlEncode ($ request); $ sign = $ client-> generateSignWithUrlEncode ($ request ); $ data ['gatewayurl'] = $ This-> gatewayUrl; $ data ['appid '] = $ this-> appId; $ data ['charset'] = $ this-> charset; $ data ['params'] = $ params; $ data ['sign'] = $ sign; return $ data;} // decrypt the public function zhimacallback ($ params) {$ this-> privateKeyFile = "path/rsa_private_keypem"; $ client = new ZmopClient ($ this-> gatewayUrl, $ this-> appId, $ this-> charset, $ this-> privateKeyFile, $ this-> zmPublicKeyFile); $ result = $ client-> generateSignCal LBack ($ params, $ this-> privateKeyFile); return $ result ;}}?>
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.