Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utf8_encode php8.2版本弃用了。抛出钉钉时候报错 #10

Open
billlv opened this issue Jun 8, 2023 · 2 comments
Open

utf8_encode php8.2版本弃用了。抛出钉钉时候报错 #10

billlv opened this issue Jun 8, 2023 · 2 comments
Labels
question Further information is requested

Comments

@billlv
Copy link

billlv commented Jun 8, 2023

首先很感谢作者的付出。插件很好用。
使用的问题请留意。一个是格式函数弃用,另外一个dingtalk key多了下划线代码对应不上。

class DingTalkRobotEvent

private static function _sign(string $url, string $secret): string
{
[$s1, $s2] = explode(' ', microtime());
$timestamp = (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
$data = $timestamp . "\n" . $secret;
$signStr = base64_encode(hash_hmac('sha256', $data, $secret, true));
#这部分做的兼容
if(PHP_VERSION_ID < 82000){
$signStr = mb_convert_encoding($signStr, 'UTF-8', 'ISO-8859-1');
} else {
$signStr = utf8_encode(urlencode($signStr));
}
$signStr = mb_convert_encoding(urlencode($signStr), 'UTF-8', 'ISO-8859-1');
return $url . "&timestamp=$timestamp&sign=$signStr";
}

@Tinywan
Copy link
Owner

Tinywan commented Jun 9, 2023

感谢反馈

@Tinywan Tinywan added the question Further information is requested label Jun 9, 2023
@Tinywan
Copy link
Owner

Tinywan commented Jun 9, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants