WeworkMsg

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

WeworkMsgSdk

全语言通用的企业微信会话存档SDK

介绍

此项目基于 https://github.com/NICEXAI/WeWorkFinanceSDK 实现

WeworkMsg 会以服务运行,对外暴露接口提供服务,开发者只需要进行 http 接口调用,无需关心各种复杂的兼容问题。

配置

  • .env 里面配置好企业的相关信息
  • 密钥信息粘贴在 private_key.pem 里面
  • PORT 为服务的端口号

运行

复制 libWeWorkFinanceSdk_C.so 动态库文件到系统动态链接库默认文件夹下,或者复制到任意文件夹并在当前文件夹下执行 export LD_LIBRARY_PATH=$(pwd)命令设置动态链接库检索地址

执行 ./WeworkMsg

运行

接口调用

服务提供了两个接口,均以 POST json 的方式进行调用

  • /get_chat_data 获取会话列表,参数例子{"seq":0,"limit":100,"timeout":3}
  • /get_media_data 获取媒体文件,参数例子{"sdk_file_id":"xxx","timeout":3}
php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
   CURLOPT_URL => 'http://localhost:8888/get_chat_data',
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_ENCODING => '',
   CURLOPT_MAXREDIRS => 10,
   CURLOPT_TIMEOUT => 0,
   CURLOPT_FOLLOWLOCATION => true,
   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
   CURLOPT_CUSTOMREQUEST => 'POST',
   CURLOPT_POSTFIELDS =>'{
    "seq": 0,
    "limit": 100,
    "timeout": 3
}',
   CURLOPT_HTTPHEADER => array(
      'Content-Type: application/json'
   ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
python
import http.client
import json

conn = http.client.HTTPSConnection("localhost", 8888)
payload = json.dumps({
   "seq": 0,
   "limit": 100,
   "timeout": 3
})
headers = {
   'Content-Type': 'application/json'
}
conn.request("POST", "/get_chat_data", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
go
package main

import (
   "fmt"
   "strings"
   "net/http"
   "io/ioutil"
)

func main() {

   url := "http://localhost:8888/get_chat_data"
   method := "POST"

   payload := strings.NewReader(`{"seq":0,"limit":100,"timeout":3}`)

   client := &http.Client {
   }
   req, err := http.NewRequest(method, url, payload)

   if err != nil {
      fmt.Println(err)
      return
   }
   req.Header.Add("Content-Type", "application/json")

   res, err := client.Do(req)
   if err != nil {
      fmt.Println(err)
      return
   }
   defer res.Body.Close()

   body, err := ioutil.ReadAll(res.Body)
   if err != nil {
      fmt.Println(err)
      return
   }
   fmt.Println(string(body))
}

如需要其他语言例子,可以提 issue

加交流群

image

相关项目

cd788338d401375c814f0fd66f4fbb81

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL