namespace app\ding\controller;
use think\Config;
class Index
{
public function getUserID($code)
{
$url = "https://oapi.dingtalk.com/user/getuserinfo?access_token=".$this->getAccessToken()."&code=".$code;
$user = $this->http($url);
return json_decode($user,JSON_UNESCAPED_UNICODE);
}
public function getUserInfo($userid)
{
$url = "https://oapi.dingtalk.com/user/get?access_token=".$this->getAccessToken()."&userid=".$userid;
$userinfo = $this->http($url);
return json_decode($userinfo,JSON_UNESCAPED_UNICODE);
}
public function getAccessToken()
{
$config = Config();
$appkey = $config['ding_auto_login_appkey'];
$appsecret = $config['ding_auto_login_appsecret'];
//定义token文件和路径,默认位于应用目录下
$token_file_name = APP_PATH.'/ding_access_token.php';
//如果token文件存在
if(file_exists($t
钉钉通过code获取用户信息的实例(PHP)
最新推荐文章于 2025-02-12 11:10:22 发布