在专有钉钉中获取用户信息前提须要获取 access_token,上面我来记录下获取 access_token 的过程
1:下载对应版本的 sdk:https://openplatform-portal.dg-work.cn/portal/#/helpdoc?docKey=gjyzy&slug=st5ct2
这里我应用的是 php,所以我下载的是 php 版的 sdk,各位能够依据本人的理论状况下载对应版本的 sdk
2:获取 access_token
// 获取 access_token
try {$executableClient = new ExecutableClient();
//Saas 环境域名为:https://openplatform.dg-work.cn, 浙政钉环境域名为:https://openplatform-pro.ding.zj.gov.cn
$executableClient->setDomain('域名');
$executableClient->setAccessKey('利用 App Key');
$executableClient->setSecretKey('利用 App Secret');
$executableClient->setApiName('/gettoken.json');
$result = $executableClient->epaasCurlGet(3);
} catch (\Exception $e) {$msg = "getFilterWords|err, code:". $e->getCode() . "|message:". $e->getMessage();
Yii::error($msg);
return false;
}
$accessToekn = '';
if (isset($result['success']) && $result['success']) {$accessToekn = $result['data']['accessToken'];
}
return $accessToekn;