information community file
Technical capability
Voice technology
Character recognition
Face and Human Body
Image technology
Language and knowledge
video technique

Verification of four elements of enterprise

Interface description

Compare and verify the consistency of enterprise name, unified social credit code, legal person name and registration certificate number, and verify the industrial and commercial information of enterprises.

Note: At present, the enterprise certification of industrial and commercial registration is supported, and the information of public institutions and law firms does not support the verification temporarily. The information of enterprises that have changed or just registered in industrial and commercial registration is expected to be verified after the approval date of enterprise publicity T+15 working days.

Online debugging

You can visit Sample Code Center Debug the interface in , you can perform signature verification, view the request content and return results of online calls, and automatically generate sample code.

Apply for probation

Please submit the interface before official use Cooperation consulting , or Submit work order , provide the company name, appid, and application scenario, and the staff can only use it after opening the permission.

Request Description

Request Example

HTTP method: POST

Request URL: https://aip.baidubce.com/rest/2.0/ocr/v1/four_factors_verification

URL parameter:

parameter value
access_token Access_token obtained through API Key and Secret Key, refer to“ Access Token acquisition

The headers are as follows:

parameter value
Content-Type application/x-www-form-urlencoded

Place the request parameters in the body. The details of the parameters are as follows:

Request Parameters

parameter Required type Optional value range explain
name yes string - Name of legal person
idcard yes string - ID card number of legal person
company yes string - Enterprise name
regnum yes string - Social unified credit code

Request Code Example

Prompt 1 : Before using the sample code, remember to replace the sample token, image address or Base64 information.

Prompt 2 : Some languages depend on classes or libraries. Please check the download address in the code comment.

 OCR - verification of four elements of enterprise curl -i -k ' https://aip.baidubce.com/rest/2.0/ocr/v1/four_factors_verification?access_token= [Call the token obtained from the authentication interface] ' --data 'idcard=registration certificate number&name=legal person name&company=enterprise name&regnum=social unified credit code' -H 'Content-Type:application/x-www-form-urlencoded'
 # encoding:utf-8

 import requests ''' OCR - verification of four elements of enterprise ''' request_url =  " https://aip.baidubce.com/rest/2.0/ocr/v1/four_factors_verification " params =  { "idcard" : "Registration Certificate No." , "name" : "Name of legal person" , "company" : "Enterprise name" , "regnum" : "Social unified credit code" } access_token =  '[Token obtained by calling the authentication interface]' request_url = request_url +  "?access_token="  + access_token headers =  { 'content-type' :  'application/x-www-form-urlencoded' } response = requests . post ( request_url , data = params , headers = headers )
 if response :
     print  ( response . json ( ) )
 package  com . baidu . ai . aip ;

 import  com . baidu . ai . aip . utils . HttpUtil ;


 /** *OCR - verification of four elements of enterprise */
 public  class  FourFactorsVerification  {

     /** *Tool class required in important tip code *FileUtil, Base64Util, HttpUtil, GsonUtils *  https://ai.baidu.com/file/658A35ABAB2D404FBF903F64D47C1F72 *  https://ai.baidu.com/file/C8D81F3301E24D2892968F09AE1AD6E2 *  https://ai.baidu.com/file/544D677F5D4E4F17B4122FBD60DB82B3 *  https://ai.baidu.com/file/470B3ACCA3FE43788B5A963BF0B625F3 *Download */
     public  static  String  fourFactorsVerification ( )  {
         //Request url
         String url =  " https://aip.baidubce.com/rest/2.0/ocr/v1/four_factors_verification " ;
         try  {
             String param =  "idcard="  +  "Registration Certificate No."  +  "&name="  +  "Name of legal person"  +  "&company="  +  "Enterprise name"  +  "&regnum="  +  "Social unified credit code" ;

             //Note that the purpose here is to simplify the encoding and obtain access_token for each request. The online environment access_token has an expiration time, and the client can cache it and retrieve it after expiration.
             String accessToken =  "[Token obtained by calling the authentication interface]" ;

             String result =  HttpUtil . post ( url , accessToken , param ) ;
             System . out . println ( result ) ;
             return result ;
         }  catch  ( Exception e )  { e . printStackTrace ( ) ;
         }
         return  null ;
     }

     public  static  void  main ( String [ ] args )  {
         FourFactorsVerification . fourFactorsVerification ( ) ;
     }
 }
 # include  <iostream>
 # include  <curl/curl.h>

 //Download link of libcurl library: https://curl.haxx.se/download.html
 //Download link of jsoncpp library: https://github.com/open-source-parsers/jsoncpp/
 const  static std :: string request_url =  " https://aip.baidubce.com/rest/2.0/ocr/v1/four_factors_verification " ;
 static std :: string fourFactorsVerification_result ;
 /** *The curl sends the callback function called by the http request. The returned body in json format is parsed in the callback function, and the parsing result is stored in the global static variable *See the libcurl document for @ param parameter definitions *@ return See the libcurl document for the definition of the return value */
 static size_t callback ( void  * ptr , size_t size , size_t nmemb ,  void  * stream )  {
     //The obtained body is stored in ptr and converted to string format first fourFactorsVerification_result = std :: string ( ( char  * ) ptr , size * nmemb ) ;
     return size * nmemb ;
 }
 /** *OCR - verification of four elements of enterprise *@ return If the call is successful, 0 will be returned. If an error occurs, other error codes will be returned */
 int  fourFactorsVerification ( std :: string & json_result ,  const std :: string & access_token )  { std :: string url = request_url +  "?access_token="  + access_token ; CURL * curl =  NULL ; CURLcode result_code ;
     int is_success ; curl =  curl_easy_init ( ) ;
     if  ( curl )  {
         curl_easy_setopt ( curl , CURLOPT_URL , url . data ( ) ) ;
         curl_easy_setopt ( curl , CURLOPT_POST ,  one ) ; curl_httppost * post =  NULL ; curl_httppost * last =  NULL ;
         curl_formadd ( & post ,  & last , CURLFORM_COPYNAME ,  "idcard" , CURLFORM_COPYCONTENTS ,  "Registration Certificate No." , CURLFORM_END ) ;
         curl_formadd ( & post ,  & last , CURLFORM_COPYNAME ,  "name" , CURLFORM_COPYCONTENTS ,  "Name of legal person" , CURLFORM_END ) ;
         curl_formadd ( & post ,  & last , CURLFORM_COPYNAME ,  "company" , CURLFORM_COPYCONTENTS ,  "Enterprise name" , CURLFORM_END ) ;
         curl_formadd ( & post ,  & last , CURLFORM_COPYNAME ,  "regnum" , CURLFORM_COPYCONTENTS ,  "Social unified credit code" , CURLFORM_END ) ;

         curl_easy_setopt ( curl , CURLOPT_HTTPPOST , post ) ;
         curl_easy_setopt ( curl , CURLOPT_WRITEFUNCTION , callback ) ; result_code =  curl_easy_perform ( curl ) ;
         if  ( result_code != CURLE_OK )  {
             fprintf ( stderr , " curl_easy_perform ( ) failed :  % s " ,
                     curl_easy_strerror ( result_code ) ) ; is_success =  one ;
             return is_success ;
         } json_result = fourFactorsVerification_result ;
         curl_easy_cleanup ( curl ) ; is_success =  zero ;
     }  else  {
         fprintf ( stderr ,  "curl_easy_init() failed." ) ; is_success =  one ;
     }
     return is_success ;
 }
 <? php
 /** *Initiate http post requests (REST APIs) and obtain the results of REST requests * @param string $url * @param string $param * @return - http response body if succeeds, else false. */
 function  request_post ( $url  =  '' ,  $param  =  '' )
 {
     if  ( empty ( $url )  ||  empty ( $param ) )  {
         return  false ;
     }

     $postUrl  =  $url ;
     $curlPost  =  $param ;
     //Initialize curl
     $curl  =  curl_init ( ) ;
     curl_setopt ( $curl ,  CURLOPT_URL ,  $postUrl ) ;
     curl_setopt ( $curl ,  CURLOPT_HEADER ,  zero ) ;
     //The result is required to be a string and output to the screen
     curl_setopt ( $curl ,  CURLOPT_RETURNTRANSFER ,  one ) ;
     curl_setopt ( $curl ,  CURLOPT_SSL_VERIFYPEER ,  false ) ;
     //Post submission method
     curl_setopt ( $curl ,  CURLOPT_POST ,  one ) ;
     curl_setopt ( $curl ,  CURLOPT_POSTFIELDS ,  $curlPost ) ;
     //Run curl
     $data  =  curl_exec ( $curl ) ;
     curl_close ( $curl ) ;

     return  $data ;
 }

 $token  =  '[Token obtained by calling the authentication interface]' ;
 $url  =  ' https://aip.baidubce.com/rest/2.0/ocr/v1/four_factors_verification?access_token= '  .  $token ;
 $bodys  =  array (
     'idcard'  = >  "Registration Certificate No." ,
     'name'  = >  "Name of legal person" ,
     'company'  = >  "Enterprise name" ,
     'regnum'  = >  "Social unified credit code"
 ) ;
 $res  =  request_post ( $url ,  $bodys ) ;

 var_dump ( $res ) ;
 using System ;
 using System . IO ;
 using System . Net ;
 using System . Text ;
 using System . Web ;

 namespace com . baidu . ai {
     public  class  FourFactorsVerification
     {
         //OCR - verification of four elements of enterprise
         public  static  string  fourFactorsVerification ( )
         {
             string token =  "[Token obtained by calling the authentication interface]" ;
             string host =  " https://aip.baidubce.com/rest/2.0/ocr/v1/four_factors_verification?access_token= "  + token ;
             Encoding encoding = Encoding . Default ;
             HttpWebRequest request =  ( HttpWebRequest ) WebRequest . Create ( host ) ; request . Method =  "post" ; request . KeepAlive =  true ;
             String str =  "idcard="  +  "Registration Certificate No."  +  "&name="  +  "Name of legal person"  +  "&company="  +  "Enterprise name"  +  "&regnum="  +  "Social unified credit code" ;
             byte [ ] buffer = encoding . GetBytes ( str ) ; request . ContentLength = buffer . Length ; request . GetRequestStream ( ) . Write ( buffer ,  zero , buffer . Length ) ;
             HttpWebResponse response =  ( HttpWebResponse ) request . GetResponse ( ) ;
             StreamReader reader =  new  StreamReader ( response . GetResponseStream ( ) , Encoding . Default ) ;
             string result = reader . ReadToEnd ( ) ; Console . WriteLine ( "OCR four elements of enterprise verification:" ) ; Console . WriteLine ( result ) ;
             return result ;
         }
     }
 }

Return description

Return parameters

field Required type explain
log_id yes uint64 Unique log ID for problem location
words_result_num yes uint32 The number of recognition results, representing the number of words_result elements
words_result yes object{} Identification results
verifyresult yes string The return value is:
-1: (The four elements are perfectly matched)
-0: (The four elements do not match completely)
namematch yes string Legal person name, 1: matching 0: mismatching 2: unable to verify
idnummatch yes string Registration certificate number, 1: matching 0: mismatching 2: unable to verify
companymatch yes string Enterprise name, 1: match 0: mismatch 2: cannot be verified
regnummatch yes string Unified social credit code, 1: matching 0: mismatching 2: unable to verify

Return to Example

 {
     "words_result_num" :  five ,
     "words_result" :  {
         "verifyresult" :  "0" ,
         "idnummatch" :  "0" ,
         "namematch" :  "1" ,
         "companymatch" :  "1" ,
         "regnummatch" :  "1"
     } ,
     "log_id" :  1584898210595034428
 }
Previous
Verification of three elements of enterprise
Next
Identification of Hong Kong, Macao and Taiwan certificates