delphi XE10.3 对接企业微信功能 (三)通讯录
通讯录也需要取得令牌
function TQyWeiXinHelp.GetQyWeiXinAPI(Ajson: TJsonObject): string;
var
URL,method: string;
vJson: TJsonObject;
Response: IHTTPResponse;
begin
Result := '';
WeChatErrcode := 0;
WeChatErrMsg := '';
URL := Ajson.S['APIURL'];
method := Ajson.S['method'];
if method='' then method:='Get';
URL := StringReplace(URL, 'access_token=%s',
'access_token=' + WeChatToken, [rfIgnoreCase]);
URL := StringReplace(URL, 'access_token=txl_access_token',
'access_token=' + WeChatTxlToken, [rfIgnoreCase]);
vJson:=TJsonObject.Create;
if method='Get' then
vJson.FromJSON(HttpGet(URL))
else
vJson.FromJSON(HttpPost(URL,WideToUTF8(Ajson.S['Ajson'])));
try
if vJson.Count > 0 then
begin
if vJson.I['errcode'] <> 0 then
begin
Result := vJson.ToJSON;
FWeChatErrcode := vJson.I['errcode'];
FWeChatErrMsg := vJson.S['errmsg'];
Gobal_Help.LogManage.WriteLog('取GetWeiXinAPI!错误信息:' + GetErrorMsgInfo);
end
else
begin
Result := vJson.ToJSON;
end;
end
Finally
FreeAndNil(vJson);
end;