使用可爱猫插件对接http 返回值 {"code":0,"data":""} 按理应该是返回有参数的
代码如下
这是api调用的函数
function send_text_msg($robwxid, $to_wxid, $msg){
// 封装返回数据结构
$data = array();
$data['type'] = 100; // Api数值(可以参考 - api列表demo)
$data['msg'] = urlencode($msg); // 发送内容
$data['to_wxid'] = $to_wxid; // 对方id
$data['robot_wxid'] = $robwxid; // 账户id,用哪个账号去发送这条消息
$response = array('data' => json_encode($data));
// 调用Api组件
$url = API_URL;
return sendSGHttp($url, $response,'post');
}
.这是调用的api
if ($type==100) {
// 判断用户发来的关键词
if($msg=='签到'){
// 自己的逻辑处理
$money = '1022';
$reply = '恭喜你,领取签到成功,当前金币剩余:' . $money;
// 封装返回数据结构
$data = array();
$data['type'] = 100; // Api数值(可以参考 - api列表demo)
$data['msg'] = urlencode($reply); // 发送内容
$data['to_wxid'] = $from_wxid; // 对方id(默认发送至来源的id,也可以发给其他人)
$data['robot_wxid'] = $robwxid; // 发消息的账号id,默认是收到消息的这个号,如登录了两个号,也可以用其他的号发出
// $data['key'] = '******'; // 忽略,在v2.3及以上启用了key验证才需要配这个
$response = array('data' => json_encode($data));
// 然后http请求
$url = 'http://*****:8073/send';
sendSGHttp($url, $response,'post');
下面是推送的数据
参数1: http日志 | 消息推送 | 事件推送完成,推送返回:{"code":0,"data":""}
【本次提交参数(URL编码前)】 type=100&from_wxid=wxid_wdcriybkffq222&final_from_wxid=wxid_wdcriybkffq222&from_name=陌颜&final_from_name=陌颜&robot_wxid=wxid_2lcy46oirpc822&msg=签到&time=1658767421&rid=10034【本次提交参数(URL编码后)】 type=100&from_wxid=wxid_wdcriybkffq222&final_from_wxid=wxid_wdcriybkffq222&from_name=%E9%99%8C%E9%A2%9C&final_from_name=%E9%99%8C%E9%A2%9C&robot_wxid=wxid_2lcy46oirpc822&msg=%E7%AD%BE%E5%88%B0&time=1658767421&rid=10034
返回
{"code":0,"data":""}
按照写法它应该是返回有参数的
// http post 参数为 data={"type":100, "msg":"恭喜你,签到已完成,获得金币5个", "to_wxid":"wxid_1xx*//xx", "robot_wxid":"wxid_fx*/x"}
下面是事件文档
// 以下为消息事件type值一览表,具体可查看接收过程demo
【事件数值】 【事件描述】
100 私聊消息
200 群聊消息
300 暂无
400 群成员增加
410 群成员减少
500 收到好友请求
600 二维码收款
700 收到转账
800 软件开始启动
900 新的账号登录完成
910 账号下线
--------------------------------------------------------------------
// 以下为API接口功能一览表,具体可查看调用过程demo
主动API功能列表
【功能名】 【demo中函数名】
发送文本消息 send_text_msg()
发送群消息并艾特某人 send_group_at_msg()
发送图片消息 send_iamge_msg()
发送视频消息 send_video_msg()
发送文件消息 send_file_msg()
发送动态表情 send_emoji_msg()
发送分享链接 send_link_msg()
发送音乐消息 send_music_msg()
取指定登录账号的昵称 get_robot_name()
取指定登录账号的头像 get_robot_headimgurl()
取登录账号列表 get_logged_account_list()
取好友列表 get_friend_list()
取群聊列表 get_group_list()
取群成员资料 get_group_member()
取群成员列表 get_group_member_list()
接收好友转账 accept_transfer()
同意群聊邀请 agree_group_invite()
同意好友请求 agree_friend_verify()
修改好友备注 modify_friend_note()
删除好友 delete_friend()
踢出群成员 remove_group_member()
修改群名称 modify_group_name()
修改群公告 modify_group_notice()
建立新群 building_group()
退出群聊 quit_group()
邀请加入群聊 invite_in_group()
data={"type":100, "msg":"恭喜你,签到已完成,获得金币5个", "to_wxid":"wxid_x", "robot_wxid":"wxid_xx"}
这是截屏
按照文档说明,发送文本的数字不应该是1么?你怎么用的是100?
以下下官网的说明:
{
"event":"EventGroupMsg",//事件标示(当前值为群消息事件)
"robot_wxid":"wxid_5hxa04j4z6pg22",//机器人wxid
"robot_name":"",//机器人昵称,一般为空
"type":1,//1/文本消息 3/图片消息 34/语音消息 42/名片消息 43/视频 47/动态表情 48/地理位置 49/分享链接 2000/转账 2001/红包 2002/小程序 2003/群邀请
"from_wxid":"1111",//群id,群消息事件才有
"from_name":"微群测",//群名字
"final_from_wxid":"sundreamer",//发该消息的用户微信id
"final_from_name":"遗忘悠剑o",//微信昵称
"to_wxid":"wxid_5hxa04j4z6pg22",//接收消息的人id,(一般是机器人收到了,也有可能是机器人发出的消息,别人收到了,那就是别人)
"msg":"图片https://b3logfile.com/bing/20201024.jpg",//消息内容(string/array) 使用时候根据不同的事件标示来定义这个值,字符串类型或者数据类型
"money":0.01 //金额,只有"EventReceivedTransfer"事件才有该参数
}