Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

微信登录,前台推送素材到后台,无法作为群发材料

[复制链接]
二头Neo_Wu 发表于 2014-10-24 16:30:26 | 显示全部楼层 |阅读模式
微信登录插件,前台推送素材到后台,无法作为群发材料

经过查看源代码。是因为前台的素材推送在造孽(也可以说是群发在作祟)

简单易懂的做法:
重新上传所有推送到后台的素材图片,随后就能正常发送了。

比较复杂的做法:
自行修改wechat插件下resourcepush.inc.php生成素材代码-line 26
$post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_GET['tid']);
if($thread['cover']) {
        $picurl = getthreadcover($thread['tid'], $thread['cover']);
} else {
        $attach = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$_GET['tid'], 'pid', array($post['pid']), '', true);
        $picurl = '';
        if($attach) {
                $attach = array_shift($attach);
                $picurl = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']).'forum/'.$attach['attachment'];
        }
}


$data = array(
        'name' => lang('plugin/wechat', 'resource_thread_push').': '.$thread['subject'],
        'data' => array(
            'title' => $thread['subject'],
            'pic' => $picurl ? (preg_match('/^http:/', $picurl) ? '' : $_G['siteurl']).$picurl : '',
            'desc' => messagecutstr($post['message'], 0, 120),
            'content' => nl2br(messagecutstr($post['message'])),
            'url' => $_G['siteurl'].'forum.php?mod=viewthread&tid='.$_GET['tid'],
        ),
);



整个过程中,$picurl未生成common目录下新的pic,也没有增加$data['data']['local'],导致报错。
或masssend_setting.inc.php的提交微信服务器端代码
-line 108
                if ($res['type'] == 0) {
                        if ($res['data']['pic']) {
                                $thumb_media_id = $wechat_client->upload('image', $_G['setting']['attachdir'] . 'common/' . $res['data']['local']);
                                if (!$thumb_media_id) {
                                        cpmsg_error($wechat_client->error());
                                }
                                $res['data']['thumb_media_id'] = $thumb_media_id;
                                $res['data']['author'] = '';
                        } else {
                                cpmsg('wechat:mass_no_pic');
                        }
                        array_push($news, $res['data']);
                } else if ($res['type'] == 1) {
                        $news = array();
                        foreach (array_keys($res['data']['mergeids']) as $resource_id) {
                                $res = C::t('#wechat#mobile_wechat_resource')->fetch($resource_id);
                                if (!$res) {
                                        cpmsg('wechat:mass_no_found');
                                }
                                if ($res['data']['pic']) {
                                        $thumb_media_id = $wechat_client->upload('image', $_G['setting']['attachdir'] . 'common/' . $res['data']['local']);
                                        if (!$thumb_media_id) {
                                                cpmsg_error($wechat_client->error());
                                        }
                                        $res['data']['thumb_media_id'] = $thumb_media_id;
                                        $res['data']['author'] = '';
                                        array_push($news, $res['data']);
                                } else {
                                        cpmsg_error('wechat:mass_no_pic');
                                }
                        }
                }
都强制使用附件common目录下内容,以至于前台生成文件与这里强行拼接不符。


希望能及时修订。

 楼主| 二头Neo_Wu 发表于 2014-10-26 12:22:53 | 显示全部楼层
本帖最后由 二头Neo_Wu 于 2014-10-26 12:24 编辑

修改了masssend_setting.inc.php
修改了2处对图片的处理
原代码:
  1. $thumb_media_id = $wechat_client->upload('image', $_G['setting']['attachdir'] . 'common/' . $res['data']['local']);
复制代码


新代码:
  1. if (!$res['data']['local']) { // 推送不存在Local
  2.         $temp = explode($_G['siteurl'], $res['data']['pic']); // 截取有效地址
  3.         $thumb_media_id = $wechat_client->upload('image', substr(dirname(__FILE__), 0, -20) . '.' . $temp[1]); // 拼接物理地址
  4. } else {
  5.         $thumb_media_id = $wechat_client->upload('image', $_G['setting']['attachdir'] . 'common/' . $res['data']['local']);
  6. }
复制代码


希望有所帮助

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-2-25 16:28 , Processed in 0.035415 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表