11111
This commit is contained in:
@@ -592,6 +592,14 @@ class Adapter implements WeChatServiceInterface
|
||||
// 建立WebSocket
|
||||
$wsController = new WebSocketController(['userName' => $username, 'password' => $password, 'accountId' => $toAccountId]);
|
||||
|
||||
// 获取发送方 wechatId(例如 wxid_xxx),用于拼接 miniprogram 的 contentXml
|
||||
$senderWxid = '';
|
||||
if (!empty($wechatAccountId)) {
|
||||
$senderWxid = Db::table('s2_wechat_account')
|
||||
->where('id', $wechatAccountId)
|
||||
->value('wechatId') ?? '';
|
||||
}
|
||||
|
||||
|
||||
$gap = 0;
|
||||
foreach ($msgConf as $messages) {
|
||||
@@ -626,7 +634,73 @@ class Adapter implements WeChatServiceInterface
|
||||
|
||||
case 'miniprogram':
|
||||
$msgType = 49;
|
||||
$detail = '';
|
||||
$title = $content['title'] ?? '';
|
||||
$des = $content['des'] ?? ($content['description'] ?? '');
|
||||
$gh = $content['gh'] ?? ($content['miniProgramId'] ?? ($content['nativeId'] ?? ''));
|
||||
$pagepath = $content['pagepath'] ?? ($content['pagePath'] ?? '');
|
||||
$previewImage = $content['previewImage'] ?? ($content['cover'] ?? ($content['thumbPath'] ?? ''));
|
||||
|
||||
$senderWxidLocal = $content['wxid'] ?? ($content['senderWxid'] ?? $senderWxid);
|
||||
|
||||
// 兼容:如果外部已经直接传了 contentXml,就不再按字段拼 xml
|
||||
if (!empty($content['contentXml']) && !empty($previewImage) && !empty($senderWxidLocal)) {
|
||||
$detailArray = [
|
||||
'contentXml' => $content['contentXml'],
|
||||
'previewImage' => $previewImage,
|
||||
'type' => 'miniprogram',
|
||||
];
|
||||
$detail = json_encode($detailArray, JSON_UNESCAPED_UNICODE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($senderWxidLocal) || empty($title) || empty($des) || empty($gh) || empty($pagepath) || empty($previewImage)) {
|
||||
$detail = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$ghUsername = (string)$gh;
|
||||
if (strpos($ghUsername, '@app') === false) {
|
||||
$ghUsername .= '@app';
|
||||
}
|
||||
|
||||
$contentXml = $senderWxidLocal . ":\n" . <<<XML
|
||||
<?xml version="1.0"?>
|
||||
<msg>
|
||||
<appmsg appid="" sdkver="0">
|
||||
<title>{$title}</title>
|
||||
<des>{$des}</des>
|
||||
<type>33</type>
|
||||
<showtype>0</showtype>
|
||||
<soundtype>0</soundtype>
|
||||
<contentattr>0</contentattr>
|
||||
<sourceusername>{$ghUsername}</sourceusername>
|
||||
<weappinfo>
|
||||
<username><![CDATA[{$ghUsername}]]></username>
|
||||
<appid><![CDATA[]]></appid>
|
||||
<type>2</type>
|
||||
<version>50</version>
|
||||
<weappiconurl><![CDATA[]]></weappiconurl>
|
||||
<pagepath><![CDATA[{$pagepath}]]></pagepath>
|
||||
<pkginfo>
|
||||
<type>0</type>
|
||||
<md5><![CDATA[]]></md5>
|
||||
</pkginfo>
|
||||
<wadynamicpageinfo>
|
||||
<shouldUseDynamicPage>0</shouldUseDynamicPage>
|
||||
<cacheKey><![CDATA[]]></cacheKey>
|
||||
</wadynamicpageinfo>
|
||||
<appservicetype>0</appservicetype>
|
||||
</weappinfo>
|
||||
</appmsg>
|
||||
</msg>
|
||||
XML;
|
||||
|
||||
$detailArray = [
|
||||
'contentXml' => $contentXml,
|
||||
'previewImage' => $previewImage,
|
||||
'type' => 'miniprogram',
|
||||
];
|
||||
$detail = json_encode($detailArray, JSON_UNESCAPED_UNICODE);
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
|
||||
Reference in New Issue
Block a user