非常感谢微信时光机的原作者SNGR,能直接在微信上发小动态真的太方便了!我也只是在其基础上稍作修改以及适配VOID主题而已。

目前,由于没有适配VOID主题,我是让动态列表直接在评论区中显示,虽然也不错,但是总觉得没内味儿。

改造目标:

  • [ ] 适配主题。

    • [x] 我放弃了。还脑洞大开做了个奇怪的东西。https://katcloud.cn/archives/79.html
    • [x] 在插入动态时添加邮箱,这样就不会有默认头像了,默认头像确实不好看。

在wxindex.php里添加两句代码就好了。(注释包裹部分)

<?php
require_once dirname(__FILE__) . '/config.inc.php';
$sgj = $db->fetchAll($db->select()->from('table.contents')->where('slug = ?',cross));
$sgjid = $sgj['0']['cid'];
$user = $db->fetchAll($db->select()->from('table.users')->limit(1));
$name = $user['0']['screenName'];
// 添加邮箱获取头像
$mail = $user['0']['mail'];
//
$time = $_POST["time"];
$content = $_POST["content"];
$imgname = $_FILES['myfile']['name'];
$tmp = $_FILES['myfile']['tmp_name'];
$filepath = 'sgjpic/';
if (isset($time)) {
  $insert = $db->insert('table.comments')->rows(array(
      "cid" => $sgjid,"created" => $time,"author" => $name,
      "authorId" =>"1","ownerId" => "1","text"=> $content,"agent"=>"weChat", 
      // insert的时候加上
      "mail"=>$mail));
      //
  $insertId = $db->query($insert);
} else {
  move_uploaded_file($tmp,$filepath.$imgname);
}
?>