configs = $configs; } /** * 获得签名信息 * @param $name * @param $gets * @param array $posts * @return string */ protected function getSignUri($name,$gets,$posts=[]){ $gets["partnerId"] = $this->configs["api_partner_id"]; $gets["name"] = $name; $gets["version"] = $this->configs["api_version"]; $gets["expires"] = time()+3600; $gets["nonce"] = uniqid(); $array=array_merge($gets,$posts); ksort($array); $str = ""; foreach ($array as $key=>$value){ $str = $str . $key . '=' . $value . '&'; } $str = substr($str, 0,strlen($str)-1); $signature = hash_hmac('SHA256',$str, $this->configs["api_key"]); $getUri=""; foreach ($gets as $key=>$value){ $getUri = $getUri . $key . '=' . $value . '&'; } return $getUri."signature=".$signature; } /** * 获得用户信息 * @param $gCorpId * @param $guid * @return mixed */ public function getUserDetail($gCorpId,$guid){ $name="b.getUserDetail"; $posts = [ "corpId" => $gCorpId, "guid" => $guid ]; $uri = $this->configs["api_url"]."/fe/private/?".$this->getSignUri($name,[],$posts); $curl = new Curl($uri); $ret = json_decode($curl->httpPost($posts),true); return $ret; } /** * 获得企业列表 * @param $page8 * @param $pageSize * @return mixed */ public function getCorpList($page,$pageSize){ $name="b.getCorpList"; $posts = [ "page" => $page, "pageSize" => $pageSize ]; $uri = $this->configs["api_url"]."/fe/private/?".$this->getSignUri($name,[],$posts); $curl = new Curl($uri); $ret = json_decode($curl->httpPost($posts),true); return $ret; } /** * 获得企业信息 * @param $gCorpId * @return mixed */ public function getCorpInfo($gCorpId){ $name="b.getCorpInfo"; $posts = [ "enterpriseId" => $gCorpId ]; $uri = $this->configs["api_url"]."/fe/private/?".$this->getSignUri($name,[],$posts); $curl = new Curl($uri); $ret = json_decode($curl->httpPost($posts),true); return $ret; } /** * 获取微信access_token * @param $appId * @param $gCorpId * @return mixed */ public function getWechatToken($gCorpId,$appId){ $name="b.wechat.getToken"; $posts = [ "appId" => $appId, "corpId" => $gCorpId ]; $uri = $this->configs["api_url"]."/fe/private/?".$this->getSignUri($name,[],$posts); $curl = new Curl($uri); $ret = json_decode($curl->httpPost($posts),true); return $ret; } /** * 获取企业微信access_token * @param $qyCorpId * @param $suiteId * @return mixed */ public function getWesuitToken($qyCorpId,$suiteId){ $name="b.wesuit.getToken"; $posts = [ "qy_corpid" => $qyCorpId, "suiteId" => $suiteId, ]; $uri = $this->configs["api_url"]."/fe/private/?".$this->getSignUri($name,[],$posts); $curl = new Curl($uri); $ret = json_decode($curl->httpPost($posts),true); return $ret; } /** * 获得爱关怀的SSO URL地址 * @param $gCorpId * @param $redirectUrl * @return string */ public function getSsoUrl($gCorpId,$redirectUrl){ return $this->configs["api_url"]."/".$this->configs["api_version"]."/huanan/sso/url?gcorpId={$gCorpId}&forward=1&redirectUrl=".urlencode($redirectUrl); } }