法大大企业账号注册对接步骤

1、获取法大大开发平台接口文档

开放平台 法大大-电子合同法律管家

2、注册账号,获取平台公共的app_id等信息,放在项目的配置文件中

 return array (
  'fdd_server' =>env('FDD_SERVER','https://testapi37.fadada.com/api/') ,
  'fdd_min_server' => env('FDD_MIN_SERVER','https://testapi18.fadada.com/api/'),
  'app_id' => env('APP_ID',402232),
  'app_secret' => env('APP_SECRET','ATTPWWQCWy3f6DxM4jIQu332'),
  'template_id' => env('TEMPLATE_ID',19741310777), //个人
  'c_template_id' => '', //企业
  'customer_id' => env('CUSTOMER_ID','9RE1A5E4DC7B58377904CAAQ1C24Q976'),
  'company_customer_id' => env('COMPANY_CUSTOMER_ID','E2Q66AF8996E66A0E943F88907099R45') //企业实名认证客户id(测试)
);

3、对接api代码实例

$user = auth()->user();
$app_id = config('fdd')['app_id'];
$app_secret = config('fdd')['app_secret'];
$timestamp = date('YmdHis');
$oopen_id =  md5(uniqid('abc_'));
$msg_digest = msgDigest($app_id,$app_secret,$timestamp,[$account_type,$oopen_id]);
$client = new Client();
$url = config('fdd')['fdd_server'].'account_register.api';
$options =
    [
        'form_params' => [
            'app_id'=>$app_id,
            'timestamp'=>$timestamp,
            'v' => 2.0,
            'msg_digest' =>$msg_digest ,
            'open_id'=>$oopen_id,
            'account_type'=>$account_type,
        ]
    ];
$res = $client->post($url,$options);
$res = $res->getBody()->getContents();
$res = json_decode($res,true) ;
if($res['code'] != 1){
    Log::channel('fadada')->error('法大大账号注册报错信息: '.'errorCode:'.$res['code'].'>>>'.'errorMsg:'.$res['msg']);
    return $this->fail('系统故障,请稍后再试!') ;
}
$customer_id = $res['data'] ;
$result = UserModel::where('id',$user->id)->update(['customer_id'=>$customer_id,'oopenid'=>$oopen_id]);
if(!$result){
    return $this->fail('系统故障,请稍后再试!');
}
return $this->success(['customer_id'=>$customer_id],'客户编号!');
function msgDigest($app_id,$app_secret,$timestamp,$option=[])
{
    $str = '';
    foreach ($option as $v) {
        $str .= $v;
    }
    if ($str) {
        return base64_encode(strtoupper(sha1($app_id . strtoupper(md5($timestamp)) . strtoupper(sha1($app_secret . $str)))));
    } else {
        return base64_encode(strtoupper(sha1($app_id . strtoupper(md5($timestamp)) . strtoupper(sha1($app_secret)))));
    }

}

你可能感兴趣的:(第三方接口对接,php,数学建模,开发语言)