调用接口:
https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN
上面的 ACCESS_TOKEN 已经让我换成实际中的 token 字段串了没问题
//模板 data
$tmpData = [
'thing1' => ['value'=>$buyUserInfo->user_name],
'thing2' => ['value'=>$productInfo->product_name],
'amount3' => ['value'=>$shopOrderModel->order_total_real_price],
'character_string4' => ['value'=>$shopOrderModel->order_sn],
'thing6' => ['value'=>$shopOrderModel->order_note]
];
$postData = [
'touser' => $shopUserConfigModel->wx_open_id,
'template_id' => 'AIaIS2CYJKSVSIEhLXa4w7TCzzhgf7utttE0d_2UUic',
'page' => 'index',
"miniprogram_state" =>"developer",
'lang' => 'zh_CN',
'data' => $tmpData,
];
参数都是按文档上要求写的
//同步请示
$client = new Client();
$res = $client->post($postUrl,['form_params'=>$postData]);
接口返回:
"errcode": 47001,
"errmsg": "data format error rid: 663c7ee6-027f88e7-0d0b7d1b"
先用postman调用排除json格式问题
接口返回:
"errcode": 47001,
"errmsg": "data format error rid: 663c7ee6-027f88e7-0d0b7d1b"