PHP code example of fadada / fasc-openapi-php-sdk

1. Go to this page and download the library: Download fadada/fasc-openapi-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fadada / fasc-openapi-php-sdk example snippets


fasc-openapi-php-sdk
    - src
        - FddCloud
            - bean //里面放的是所有API的对象参数
	            - message //里面放的是所有事件回调的对象参数
	            - req //里面放的是所有接口请求的对象参数
            - constants //里面放的是接口url地址和应用的配置信息
            - client //对应接口各个模块的client,接入方可以参考下面用例初始化client后调用
            - utils //里面是封装好工具类,接入方开发人员可以参考   
	

    /** 引入自动加载 */
    

    use FddCloud\constants\OpenApiConfig;
    
    /**读取配置文件**/
    $apiConfigFile = 'api_config.php';
    $openApiConfig = new OpenApiConfig($apiConfigFile);
    $app_id = $openApiConfig->getConfig()['app_id'];
    $app_secret = $openApiConfig->getConfig()['app_secret'];
    $service_url = $openApiConfig->getConfig()['service_url'];
    $time_out = $openApiConfig->getConfig()['time_out'];
    $debug = $openApiConfig->getConfig()['debug'];
 

    use FddCloud\client\Client;
    
	$client = new Client(
            $app_id,$app_secret,$service_url,$time_out,$debug
        );
  

    /** 获取accessToken */
    $serviceClient = new ServiceClient($client);
    $response = $serviceClient->getAccessToken();
    print_r($response . "\n");
    $res = json_decode($response);
  

    use FddCloud\bean\req\user\GetUserAuthUrlReq;
	
	/**获取userClient**/
    $userClient = new UserClient($client);
    
    $getUserAuthUrlReq = new GetUserAuthUrlReq();
    # 个人用户在应用中的唯一标识,长度最大64个字符
    $getUserAuthUrlReq->setClientUserId("");
    # 个人用户的法大大帐号,仅限手机号或邮箱,长度最大30个字符。如该手机号或邮箱未注册法大大,则用户会以此作为注册账号
    $getUserAuthUrlReq->setAccountName("");
    $getUserAuthUrlReq->setNonEditableInfo($nonEditableInfo);
    $authScope = ["ident_info", "seal_info", "signtask_init", "signtask_info", "signtask_file","file_storage"];
    $getUserAuthUrlReq->setAuthScopes($authScope);
    # 重定向地址,即用户在返回的页面上完成操作后重定向跳转到该地址,并且附带上参数。该地址是应用系统的地址,以实现用户交互在应用系统和法大大平台之间的连贯性。长度最大500个字符
    $getUserAuthUrlReq->setRedirectUrl(urlencode("https://www.163.com/"));
    # 小程序的重定向地址(微信和支付宝),长度最大1000个字符。
    # 使用场景:小程序中集成该页面,操作完成后跳转地址为小程序原生页面路径,如"/pages/index/index",系统判断在小程序环境会跳转至该地址。
    # 注:需要进行编码,若非原生页面路径请使用redirectUrl字段
    $getUserAuthUrlReq->setRedirectMiniAppUrl("");
    $response = $client->getUserAuthUrl($accessToken, $getUserAuthUrlReq);
    print_r($response . "\n");
bash
$ composer