求推荐php对接微信订阅号

511
@Ta 2023-02-26 17572点击
目前在用Easy的,去年开始经常接受信息后会出现以下图片的提示,但是回复内容之类的都是正常的,是我没更新Easy的原因还是咋了,是突然出现的,那段时间没去碰这个程序,有没有老哥推荐推荐这种程序呀Screenshot_2023-02-26-13-08-49-920_com.tencent.mm.png(14.89 KB)
回复列表(18|隐藏机器人聊天)
  • 511
    @Ta / 2023-02-27 / /
    哇哈哈
  • @Ta / 2023-02-27 / /

    虎绿林在用WXPusher做消息推送

  • @Ta / 2023-02-27 / /

    @老虎会游泳,其实我想利用chatgpt写出一个WXPusher差不多的程序。
    一加8Pro

  • @Ta / 2023-02-27 / /

    @加勒比海带,以下是一个类似于WXPusher的Python程序的示例代码:

    import requests
    
    class Pusher:
        def __init__(self, app_token, user_ids):
            self.app_token = app_token
            self.user_ids = user_ids
    
        def send_message(self, topic, content):
            url = 'https://wxpusher.zjiecode.com/api/send/message'
            headers = {'Content-Type': 'application/json'}
            data = {
                'appToken': self.app_token,
                'content': content,
                'contentType': 1,
                'topicIds': [topic],
                'uids': self.user_ids
            }
            response = requests.post(url, headers=headers, json=data)
            if response.status_code == 200:
                print('Message sent successfully')
            else:
                print('Message failed to send')
    
    if __name__ == '__main__':
        app_token = 'your_app_token'
        user_ids = ['user_id_1', 'user_id_2']
        pusher = Pusher(app_token, user_ids)
        topic = 'test_topic'
        content = 'test_message'
        pusher.send_message(topic, content)
    

    这个示例程序定义了一个名为Pusher的类,它具有初始化方法和send_message方法。初始化方法用于初始化app_token和user_ids属性。send_message方法接受topic和content参数,并将它们作为数据发送到指定的URL。程序使用requests库来发送HTTP请求,并处理响应状态码以检查消息是否成功发送。

    在main函数中,我们首先初始化一个Pusher对象,然后指定要发送的topic和content,最后调用send_message方法发送消息。

    请注意,此示例程序仅用于演示目的。如果您打算将其用于生产环境,请考虑添加错误处理、异常处理和安全措施等功能。

  • @Ta / 2023-02-27 / /

    @加勒比海带,当然可以,以下是类似于WXPusher的Golang程序的示例代码:

    package main
    
    import (
        "bytes"
        "encoding/json"
        "fmt"
        "net/http"
    )
    
    type Pusher struct {
        AppToken string   `json:"appToken"`
        UserIds  []string `json:"uids"`
    }
    
    type Message struct {
        AppToken    string   `json:"appToken"`
        Content     string   `json:"content"`
        ContentType int      `json:"contentType"`
        TopicIds    []string `json:"topicIds"`
        Uids        []string `json:"uids"`
    }
    
    func (p *Pusher) Send(topic string, content string) error {
        url := "https://wxpusher.zjiecode.com/api/send/message"
        pusher := Pusher{AppToken: p.AppToken, UserIds: p.UserIds}
        message := Message{AppToken: p.AppToken, Content: content, ContentType: 1, TopicIds: []string{topic}, Uids: p.UserIds}
        data, err := json.Marshal(message)
        if err != nil {
            return err
        }
        resp, err := http.Post(url, "application/json", bytes.NewReader(data))
        if err != nil {
            return err
        }
        if resp.StatusCode != http.StatusOK {
            return fmt.Errorf("Message failed to send")
        }
        return nil
    }
    
    func main() {
        appToken := "your_app_token"
        userIds := []string{"user_id_1", "user_id_2"}
        pusher := Pusher{AppToken: appToken, UserIds: userIds}
        topic := "test_topic"
        content := "test_message"
        err := pusher.Send(topic, content)
        if err != nil {
            fmt.Println(err)
        } else {
            fmt.Println("Message sent successfully")
        }
    }
    

    这个示例程序使用Golang实现了一个名为Pusher的结构体,它具有AppToken和UserIds属性以及Send方法。Send方法接受topic和content参数,并将它们作为数据发送到指定的URL。程序使用标准库net/http和encoding/json来发送HTTP请求,并处理响应状态码以检查消息是否成功发送。

    在main函数中,我们首先初始化一个Pusher结构体对象,然后指定要发送的topic和content,最后调用Send方法发送消息。

    请注意,此示例程序仅用于演示目的。如果您打算将其用于生产环境,请考虑添加错误处理、异常处理和安全措施等功能。

  • @Ta / 2023-02-27 / /

    @加勒比海带,以下是一个类似于WXPusher的C语言程序的示例代码:

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <curl/curl.h>
    #include <cjson/cJSON.h>
    
    #define MAX_RESPONSE_SIZE 4096
    
    typedef struct Pusher {
        char *appToken;
        char **userIds;
        int numUsers;
    } Pusher;
    
    typedef struct Message {
        char *appToken;
        char *content;
        int contentType;
        char **topicIds;
        int numTopics;
        char **uids;
        int numUids;
    } Message;
    
    size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) {
        size_t real_size = size * nmemb;
        char *response = (char *)userdata;
        strncat(response, ptr, real_size);
        return real_size;
    }
    
    void pusher_init(Pusher *pusher, char *appToken, char **userIds, int numUsers) {
        pusher->appToken = strdup(appToken);
        pusher->userIds = (char **)malloc(numUsers * sizeof(char *));
        for (int i = 0; i < numUsers; i++) {
            pusher->userIds[i] = strdup(userIds[i]);
        }
        pusher->numUsers = numUsers;
    }
    
    void pusher_cleanup(Pusher *pusher) {
        free(pusher->appToken);
        for (int i = 0; i < pusher->numUsers; i++) {
            free(pusher->userIds[i]);
        }
        free(pusher->userIds);
    }
    
    void message_init(Message *message, char *appToken, char *content, int contentType, char **topicIds, int numTopics, char **uids, int numUids) {
        message->appToken = strdup(appToken);
        message->content = strdup(content);
        message->contentType = contentType;
        message->topicIds = (char **)malloc(numTopics * sizeof(char *));
        for (int i = 0; i < numTopics; i++) {
            message->topicIds[i] = strdup(topicIds[i]);
        }
        message->numTopics = numTopics;
        message->uids = (char **)malloc(numUids * sizeof(char *));
        for (int i = 0; i < numUids; i++) {
            message->uids[i] = strdup(uids[i]);
        }
        message->numUids = numUids;
    }
    
    void message_cleanup(Message *message) {
        free(message->appToken);
        free(message->content);
        for (int i = 0; i < message->numTopics; i++) {
            free(message->topicIds[i]);
        }
        free(message->topicIds);
        for (int i = 0; i < message->numUids; i++) {
            free(message->uids[i]);
        }
        free(message->uids);
    }
    
    int pusher_send(Pusher *pusher, Message *message) {
        CURL *curl;
        CURLcode res;
        char url[256];
        char response[MAX_RESPONSE_SIZE] = "";
        cJSON *json, *data;
        int ret = -1;
    
        curl_global_init(CURL_GLOBAL_ALL);
        curl = curl_easy_init();
        if (curl) {
            sprintf(url, "https://wxpusher.zjiecode.com/api/send/message?appToken=%s&contentType=%d", message->appToken, message->contentType);
            for (int i = 0; i < message->numTopics; i++) {
                sprintf(url, "%s&topicIds[]=%s", url, message
    
  • @Ta / 2023-02-27 / /

    @ChatGPT,用php写下

  • @Ta / 2023-02-27 / /

    [新会话] @布偶,很好,请问您需要我用PHP写些什么?一个简单的示例可能是:

    <?php
      // 输出“Hello, World!”
      echo "Hello, World!";
    ?>
    

    这个示例中,我们使用PHP语言输出了一行文本“Hello, World!”。

  • 511
    @Ta / 2023-02-27 / /
    @ChatGPT 写一个WXPusher的php
  • @Ta / 2023-02-27 / /

    @511,发言失败,请重试。当前会话已丢失。

  • 511
    @Ta / 2023-02-27 / /
    @老虎会游泳,我知道,我是想自己做订阅号,用户绑定后方便查询
  • @Ta / 2023-02-28 / /

    @511,你的微信公众号应该没有主动发送消息的权限

  • 511
    @Ta / 2023-02-28 / /
    @老虎会游泳,没有,但是我主要是客户发送指定指令,我对接数据库查询后回复的
  • 511
    @Ta / 2023-02-28 / /
    @ChatGPT 写一个WXPusher的php
  • @Ta / 2023-02-28 / /

    @511,发言失败,请重试。当前会话已丢失。

  • @Ta / 2023-02-28 / /

    @ChatGPT 写一个WXPusher的php

  • @Ta / 2023-02-28 / /

    @ChatGPT,用PHP写一个自动回复的微信机器人

  • @Ta / 2023-02-28 / /

    @老虎会游泳,发言失败,请重试。当前会话已丢失。

添加新回复
回复需要登录