这次就教大家如何用Python实现一个可以自动与你的微信好友对话的机器人吧,原理和操作都比较简单,不会编程的小白也能轻松做到,下面我们开始。

一、我们的机器人用的是GeWe框架的API,所以在开始之前,你需要有一个GeWe框架的APIKey,你可以到GeWe框架的官方网站来申请APIKey。

请求参数

Header 参数

export interface ApifoxModel {
    "X-GEWE-TOKEN": string;
    [property: string]: any;
}

Body 参数application/json

export interface ApifoxModel {
    /**
     * 设备ID
     */
    appId: string;
    /**
     * 好友的wxid
     */
    wxids: string[];
    [property: string]: any;
}

示例

{
    "appId": "",
    "wxids": [
        "wxid_phyyedw9xap22"
    ]
}

示例代码

curl --location --request POST 'http://api.geweapi.com/gewe/v2/api/contacts/getBriefInfo' \
--header 'X-GEWE-TOKEN: ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "appId": "",
    "wxids": [
        "wxid_phyyedw9xap22"
    ]
}'

返回响应

成功(200)

HTTP 状态码: 200 内容格式: JSON application/json

数据结构

export interface ApifoxModel {
    data: Datum[];
    msg: string;
    ret: number;
    [property: string]: any;
}

export interface Datum {
    alias?: string;
    bigHeadImgUrl?: string;
    cardImgUrl?: null;
    city?: string;
    country?: string;
    description?: null;
    labelList?: string;
    nickName?: string;
    phoneNumList?: null;
    province?: string;
    pyInitial?: string;
    quanPin?: string;
    remark?: string;
    remarkPyInitial?: string;
    remarkQuanPin?: string;
    sex?: number;
    signature?: null;
    smallHeadImgUrl?: string;
    snsBgImg?: null;
    userName?: string;
    [property: string]: any;
}

示例

{
    "ret": 200,
    "msg": "获取联系人信息成功",
    "data": [
        {
            "userName": "wxid_phyyedw9xap22",
            "nickName": "Ashley",
            "pyInitial": "ASHLEY",
            "quanPin": "Ashley",
            "sex": 2,
            "remark": "",
            "remarkPyInitial": "",
            "remarkQuanPin": "",
            "signature": null,
            "alias": "zero-one_200906",
            "snsBgImg": null,
            "country": "AD",
            "bigHeadImgUrl": "https://wx.qlogo.cn/mmhead/ver_1/buiaXybHTBK3BuGr1edN72zBDermWVFJ7YC8Jib2RcCSdiauAtZcPgUQpdhE9KY5NsumDAWD16fsg3A6OKuhdEr97VAHdTGgk6R1Eibuj7ZNwJ4/0",
            "smallHeadImgUrl": "https://wx.qlogo.cn/mmhead/ver_1/buiaXybHTBK3BuGr1edN72zBDermWVFJ7YC8Jib2RcCSdiauAtZcPgUQpdhE9KY5NsumDAWD16fsg3A6OKuhdEr97VAHdTGgk6R1Eibuj7ZNwJ4/132",
            "description": null,
            "cardImgUrl": null,
            "labelList": "",
            "province": "",
            "city": "",
            "phoneNumList": null
        }
    ]
}
Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐