Skip to content

Commit b82a760

Browse files
committed
fix:更新网关请求地址
1 parent 7061a3b commit b82a760

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dingtalk-stream",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Nodejs SDK for DingTalk Stream Mode API, Compared with the webhook mode, it is easier to access the DingTalk",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import WebSocket from 'ws';
22
import axios from 'axios';
33
import EventEmitter from 'events';
4-
import { GraphAPIResponse } from './constants';
4+
import { GET_TOKEN_URL, GATEWAY_URL,GraphAPIResponse } from './constants';
55

66
export enum EventAck {
77
SUCCESS = "SUCCESS",
@@ -153,12 +153,12 @@ export class DWClient extends EventEmitter {
153153
this.printDebug('get connect endpoint by config');
154154
this.printDebug(this.config);
155155
const result = await axios.get(
156-
`https://oapi.dingtalk.com/gettoken?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}`
156+
`${GET_TOKEN_URL}?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}`
157157
);
158158
if (result.status === 200 && result.data.access_token) {
159159
this.config.access_token = result.data.access_token;
160160
const res = await axios({
161-
url: 'https://pre-api.dingtalk.com/v1.0/gateway/connections/open',
161+
url: GATEWAY_URL,
162162
method: 'POST',
163163
responseType: 'json',
164164
data: {

src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export const GATEWAY_URL = 'https://api.dingtalk.com/v1.0/gateway/connections/open';
2+
export const GET_TOKEN_URL = 'https://oapi.dingtalk.com/gettoken';
3+
14

25
/** 机器人消息回调 */
36
export const TOPIC_ROBOT = '/v1.0/im/bot/messages/get';

0 commit comments

Comments
 (0)