当前位置: 移动技术网 > IT编程>网页制作>CSS > 跳转到微信指定扫码关注网页

跳转到微信指定扫码关注网页

2018年10月25日  | 移动技术网IT编程  | 我要评论

    跳转到微信指定扫码关注网页,轻松添加好友、关注公众号

    示例代码

    以下代码仅是示范用的伪代码,所使用的接口需要用户自行实现。

    通讯录接口

    企业微信开放了两种权限,通讯录的读取以及编辑权限,下面以新增一个部门为例(其他接口与之类似):

    第一步:获取通讯录应用的access_token

    public function getaccesstoken($corpid,$secret) { //todo: access_token 应该全局存储与更新,以下代码以写入到文件中做示例 //todo: 每个应用的access_token应独立存储,此处用secret作为区分应用的标识 $path = "../cache/$secret.php"; $data = json_decode(get_php_file($path)); if($data->expire_time < time()) { $url = "https://qyapi.weixin.qq.com/cgi-bin/gettokencorpid=$corpid&corpsecret=$secret"; $res = json_decode(http_get($url)["content"]); $access_token = $res->access_token; if($access_token) { $data->expire_time = time() + 7000; $data->access_token = $access_token; set_php_file($path, json_encode($data)); } } else { $access_token = $data->access_token; } return $access_token; }

    第二步:封装数据包发送到企业微信后台

    $info = $array("name" => "新增部门名称", "parentid" => 1, "order" => 10, "id" => 12); //todo:此处传入你的企业corpid以及通讯录应用的secret信息 $txl_access_token = getaccesstoken("corpid","txl_secret"); print(http_post("https://qyapi.weixin.qq.com/cgi-bin/department/createac

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网