A case study on the pit _php of PHP butt-Sesame Credit tread

Source: Internet
Author: User

As a result of the project needs, access to sesame Credit to the user certification, open Sesame Credit official website (https://b.zmxy.com.cn/index.htm) to view the official demo, in the document see as shown

Instantly feel this official demo of the rubbish.

The following needs to be noted:

1. Local generation key, you can follow the prompts to generate

2. Create the application in "Merchant Management", get the key of sesame credit by the key generated in the first step, and get the key for encryption

Note: Sesame Credit to the public key can only copy, but the copied form is wrong, we need to hand-handle each line 64, and we generated the same key format, or encryption and decryption will not be carried out;

3. Parameters to be passed according to the document can be drawn, the above figure just generated a parameter, need to process the production of the corresponding document data return;

Directly on the code:

<?php include ('/zmopclientphp '); 
  Include ('/zhimaauthinfoauthorizerequestphp '); 
    Class Testauthfreeze {//Sesame Credit gateway address public $GATEWAYURL = "Https://zmopenapizmxycomcn/openapido"; 
    Merchant Public key File//Sesame Public $privateKeyFile = "PATH/RSA_PRIVATE_KEYPEM"; 
 
    Public $zmPublicKeyFile = "PATH/ZIMA_PUBLIC_KEYPEM"; 
    Data encoding format public $charset = "UTF-8"; 
 
 
  AppId Public $appId = "1000003", which is assigned to the merchant by Sesame Seed; Generate the sign parameters required for the mobile-side SDK integration and perform UrlEncode public function generatesign ($certNo, $name, $certType = ' Identity_card ') {$clie NT = new Zmopclient ($this->gatewayurl, $this->appid, $this->charset, $this->privatekeyfile, $this-> 
    Zmpublickeyfile); 
    $request = new Zhimaauthinfoauthorizerequest (); 
    $request->setscene ("test"); 
    The authorized source channel is set to Appsdk $request->setchannel ("Appsdk"); 
    The authorization type is set to 2 identification for the license number authorization See "Chapter 4 Business Entry parameter Description identity_type" $request->setidentitytype ("2"); The construction of authorized business entry identification number, name, certificate type; Business Entry parameter description in Chapter 4 Identity_param"$request->setidentityparam (" {\ "certno\": \ "$certNo \", "certtype\": \ "identity_card\", \ "name\": \ "$name \"}); 
     
    Construct business parameter extension parameters "business entry parameter description in Chapter 4 Biz_params" $request->setbizparams ("{\ auth_code\": \ "M_appsdk\"} "); 
    $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 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->generatesigncallback ($params, $this->privatekeyfile); 
  return $result;  }}?>

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.