Skip to content

Commit

Permalink
fix:更新网关请求地址
Browse files Browse the repository at this point in the history
  • Loading branch information
junlonghuo committed Oct 18, 2023
1 parent 7061a3b commit b82a760
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dingtalk-stream",
"version": "2.1.0",
"version": "2.1.1",
"description": "Nodejs SDK for DingTalk Stream Mode API, Compared with the webhook mode, it is easier to access the DingTalk",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
6 changes: 3 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import WebSocket from 'ws';
import axios from 'axios';
import EventEmitter from 'events';
import { GraphAPIResponse } from './constants';
import { GET_TOKEN_URL, GATEWAY_URL,GraphAPIResponse } from './constants';

export enum EventAck {
SUCCESS = "SUCCESS",
Expand Down Expand Up @@ -153,12 +153,12 @@ export class DWClient extends EventEmitter {
this.printDebug('get connect endpoint by config');
this.printDebug(this.config);
const result = await axios.get(
`https://oapi.dingtalk.com/gettoken?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}`
`${GET_TOKEN_URL}?appkey=${this.config.clientId}&appsecret=${this.config.clientSecret}`
);
if (result.status === 200 && result.data.access_token) {
this.config.access_token = result.data.access_token;
const res = await axios({
url: 'https://pre-api.dingtalk.com/v1.0/gateway/connections/open',
url: GATEWAY_URL,
method: 'POST',
responseType: 'json',
data: {
Expand Down
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export const GATEWAY_URL = 'https://api.dingtalk.com/v1.0/gateway/connections/open';
export const GET_TOKEN_URL = 'https://oapi.dingtalk.com/gettoken';


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

0 comments on commit b82a760

Please sign in to comment.