@@ -14,7 +14,7 @@ class OpenWeWork extends Base
1414{
1515 public const NAME = 'open-wework ' ;
1616 protected bool $ detailed = false ;
17- protected ?int $ suiteTicket ;
17+ protected ?string $ suiteTicket ;
1818 protected ?int $ agentId ;
1919 protected ?string $ suiteAccessToken ;
2020 protected string $ baseUrl = 'https://qyapi.weixin.qq.com ' ;
@@ -108,7 +108,7 @@ protected function getSuiteAccessToken(): string
108108 protected function getUser (string $ token , string $ code ): array
109109 {
110110 $ response = $ this ->getHttpClient ()->get (
111- $ this ->baseUrl . '/cgi-bin/user /getuserinfo3rd ' ,
111+ $ this ->baseUrl . '/cgi-bin/service /getuserinfo3rd ' ,
112112 [
113113 'query ' => array_filter (
114114 [
@@ -188,22 +188,21 @@ protected function mapUserToObject(array $user): User
188188 */
189189 protected function requestSuiteAccessToken (): string
190190 {
191- $ response = $ this ->getHttpClient ()->get (
192- $ this ->baseUrl . '/cgi-bin/get_suite_token ' ,
191+ $ response = $ this ->getHttpClient ()->post (
192+ $ this ->baseUrl . '/cgi-bin/service/ get_suite_token ' ,
193193 [
194- 'query ' => array_filter (
194+ 'json ' =>
195195 [
196196 'suite_id ' => $ this ->config ->get ('suite_id ' ) ?? $ this ->config ->get ('client_id ' ),
197197 'suite_secret ' => $ this ->config ->get ('suite_secret ' ) ?? $ this ->config ->get ('client_secret ' ),
198198 'suite_ticket ' => $ this ->suiteTicket ,
199199 ]
200- ),
201200 ]
202201 );
203202
204- $ response = \json_decode ($ response ->getBody (), true ) ?? [];
203+ $ response = \json_decode ($ response ->getBody ()-> getContents () , true ) ?? [];
205204
206- if (($ response ['errcode ' ] ?? 1 ) > 0 ) {
205+ if (isset ($ response ['errcode ' ]) && $ response [ ' errcode ' ] > 0 ) {
207206 throw new AuthorizeFailedException ('Failed to get api access_token: ' . $ response ['errmsg ' ] ?? 'Unknown. ' , $ response );
208207 }
209208
0 commit comments