[Enterprise] by means of micro-channel official api get private persons (phone number, address) information

[Demand] business is a good micro-channel enterprise management tools platform, with support micro-channel has 10 million users, enables efficient communication and interaction work. When carrying out the development of micro-channel business, often need to obtain private information officers (including phone, address, department and position, etc.), therefore recorded.

【achieve】

① using the official Demo, https://github.com/sbzhu/weworkapi_php encapsulated in a lot more ways you can use directly, I believe the official point better than most self package.

② code implementation:

<?php
error_reporting(0);
header("Content-Type: text/html;charset=utf-8");
if(!isset($_GET['code'])){
    exit("请在公司平台使用!");
}
include_once ("api/src/CorpAPI.class.php");//微信官方demo中的apiwj
$api = new CorpAPI($corpId = 'ww54d5a84b1****', $secret = 'vwM2j6ksXzG-RRXBzVumxkQhQQkhQd******I');//corpId为企业微信id,secret为自建应用的secret
$user = $api->GetUserInfoByCode($_GET['code']);
$UserTicket=$user->user_ticket;
if($UserTicket==null){
    exit("sorry,没有获取到相关权限!");
}
$Info=$api->GetUserDetailByUserTicket($UserTicket);
//用户名
echo $Info->name;
//手机号
echo $Info->mobile;
?>

 

Published 44 original articles · won praise 21 · views 30000 +

Guess you like

Origin blog.csdn.net/gzyh_tech/article/details/88565966