12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace wx\work;
- class Externalcontact extends Work
- {
- public function __construct($corpid, $corpsecret)
- {
- parent::__construct($corpid, $corpsecret);
- }
- /**
- * 外部联系人openid转换
- * @param external_userid string 外部联系人userid
- * @return string openid
- */
- public function convertToOpenid($external_userid)
- {
- $url = 'https://qyapi.weixin.qq.com/cgi-bin/externalcontact/convert_to_openid?access_token='.$this->accessToken;
- $res = $this->curl($url, json_encode(['external_userid'=>$external_userid]));
- $res = json_decode($res, true);
- if (isset($res['errcode']) && $res['errcode'] != 0) {
- trace('外部联系人openid转换失败:'.$res['errmsg']);
- return null;
- }
-
- return $res['openid'];
- }
- }
|