在當(dāng)今社交網(wǎng)絡(luò)盛行的時代苛骨,微信已成為人們生活中不可或缺的工具悬嗓。為了更好地服務(wù)用戶蒜绽,許多企業(yè)和個人開始利用微信機器人來自動化回復(fù)消息、發(fā)布信息等操作滋饲。本文將介紹如何使用Java基于Gewe框架開發(fā)一個簡單的微信機器人厉碟,并提供示例代碼。
請求參數(shù)
Header 參數(shù)
export interface ApifoxModel {
? ? "X-GEWE-TOKEN": string;
? ? [property: string]: any;
}
Body 參數(shù)application/json
export interface ApifoxModel {
? ? /**
? ? * 設(shè)備ID
? ? */
? ? appId: string;
? ? /**
? ? * 備注的備注
? ? */
? ? remark: string;
? ? /**
? ? * 好友的wxid
? ? */
? ? wxid: string;
? ? [property: string]: any;
}
示例
{
? ? "appId": "",
? ? "wxid": "wxid_phyyedw9xap22",
? ? "remark": "備注"
}
示例代碼
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("http://api.geweapi.com/gewe/v2/api/contacts/setFriendRemark")
? .header("X-GEWE-TOKEN", "")
? .header("Content-Type", "application/json")
? .body("{\n? ? \"appId\": \"\",\n? ? \"wxid\": \"wxid_phyyedw9xap22\",\n? ? \"remark\": \"備注\"\n}")
? .asString();
返回響應(yīng)
成功(200)
HTTP 狀態(tài)碼: 200 內(nèi)容格式: JSONapplication/json
數(shù)據(jù)結(jié)構(gòu)
export interface ApifoxModel {
? ? msg: string;
? ? ret: number;
? ? [property: string]: any;
}
示例
{
? ? "ret": 200,
? ? "msg": "設(shè)置好友權(quán)限成功"
}