PHP调用Demo
<p><code>为PHP7.2 32位写了特殊的扩展接口,php调用代码如下:</code></p>
<p><code>该语言接口需单独付费,需要请联系我</code></p>
<pre><code class="language-php">&lt;?php
$wxloader_file = &quot;C:\\php-7.2.21-x86\\WxLoader.dll&quot;;
$wxhelper_file = &quot;C:\\php-7.2.21-x86\\WeChatHelper.dll&quot;;
$init_status = WE_Init($wxloader_file);
if ($init_status != 1)
{
echo &quot;微信扩展初始化失败\n&quot;;
exit(0);
}
$wechat_version = WE_GetWeChatVersion();
echo &quot;当前安装的微信版本是:&quot; . $wechat_version . &quot;\n&quot;;
$wechat_pid = WE_OpenWeChat($wxhelper_file);
if ($wechat_pid == 0)
{
echo &quot;打开微信失败\n&quot;;
exit(0);
}
echo &quot;打开的微信进程ID:&quot; . $wechat_pid . &quot;\n&quot;;
$g_accpet_callback = function($client_id)
{
echo &quot;有新客户端进入:&quot; . $client_id . &quot;\n&quot;;
};
$g_recv_callback = function($client_id, $data, $data_size)
{
echo &quot;接收消息:&quot; . $data . &quot;\n&quot;;
$data_obj = json_decode($data, true);
if ($data_obj['type'] == 11025)
{
$msg_data = [
'type'=&gt; 11036,
'data'=&gt; [
'to_wxid'=&gt; 'filehelper',
'content'=&gt; '该消息来自php7.2原生调用!'
]
];
sleep(1);
echo json_encode($msg_data) . &quot;\n&quot;;
WE_SendData($client_id, json_encode($msg_data));
}
};
$g_close_callback = function($client_id)
{
echo &quot;有客户端退出:&quot; . $client_id . &quot;\n&quot;;
};
// 主体循环
WE_MainLoop($g_accpet_callback, $g_recv_callback, $g_close_callback);</code></pre>