5

专有钉钉获取access_token

 3 years ago
source link: https://segmentfault.com/a/1190000040256800
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

专有钉钉获取access_token


在专有钉钉中获取用户信息前提需要获取access_token,下面我来记录下获取access_token的过程

1:下载对应版本的sdk:https://openplatform-portal.d...

这里我使用的是php,所以我下载的是php版的sdk,各位可以根据自己的实际情况下载对应版本的sdk
image.png
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;

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK