钉钉事件订阅加解密库DingCallbackCrypto(thinkphp6)学习

目的:开通事件订阅功能
环境
php 7.2 htinkphp6
DingCallbackCrypto参数
企业内部开发
H5微应用

<?php
/**
 * PHP7.1及其之上版本的回调加解密类库
 * 该版本依赖openssl_encrypt方法加解密,注意版本依赖 (PHP 5 >= 5.3.0, PHP 7)
 */
class DingCallbackCrypto
{
    private $m_token;
    private $m_encodingAesKey;
    private $m_corpId;
    //注意这里修改为构造函数
    function __construct($token, $encodingAesKey, $ownerKey)
    {
        $this->m_token = $token;
        $this->m_encodingAesKey = $encodingAesKey;
        $this->m_corpId = $ownerKey;
	}
	

$token encodingAesKey分别对应以下图片内的值
在这里插入图片描述
坑我不能保存成功的问题参数 $ownerKey
我已为是corpid导致出现以下错误
在这里插入图片描述
最后改为
在这里插入图片描述
appkey后保存成功
测试代码

     /**
     * 钉钉订阅考勤事件测试
     */
  public   function onDing(){
	  
    	if ($this->request->isPost()) { 
        $post = json_decode(file_get_contents("php://input"), true);   
		$crypt = new DingCallbackCrypto("你自己的","你自己的", "你自己的");
		  
			 $msg_signature=$this->request->param("msg_signature");
			 $timestamp= $this->request->param("timestamp");
		     $nonce= $this->request->param("nonce");  
			 $res=$crypt->getEncryptedMap("success");
		 
  return $res;
}    
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值