1、后端为laravel+easywechat
2、发送图文消息部分代码
$items = [
new NewsItem([
'title' => '这是标题',
'description' => '这是描述',
'url' => $this->getUrlLink('mallPages/info', "id={$goodsId}&agentId={$returnAgentId}"),
'image' => $goodsInfo->pic
]),
];
return new News($items);
3、getUrlLink方法
public function getUrlLink($path, $query)
{
$Curl = new Curl();
$res = $Curl->post("https://api.weixin.qq.com/wxa/generate_urllink?access_token={$this->getAccessToken()}",
json_encode([
'path' => $path,
'query' => $query,
'is_expire' => true,
'expire_type' => 1,
'expire_interval' => 3,
])
);
return $res->url_link ;
}
思路很简单,就是发送图文消息,将url参数设置为小程序URL Link即可