Giter Site home page Giter Site logo

Comments (25)

hexsum avatar hexsum commented on May 17, 2024 1

@csrgxtu
千辛万苦总算搞定了,可以使用最新的github代码进行测试

1、微信上传文件最大限制20M,否则上传失败,api接口会给出超过大小限制提示

2、小于512K的文件会直接一次性上传
原先上传大文件,时间比较长,可能会导致api接口等待超时,把api接口的内部超时时间从15s改为120s,会有所有改善

3、大于512K的文件会自动按照512K分片依次上传,如果开启了debug日志会看到分片上传的过程,比如

[16/12/29 23:36:08] [debug] 正在上传媒体[xxx.mp4],当前进度:1/4
[16/12/29 23:36:10] [debug] 正在上传媒体[xxx.mp4],当前进度:2/4
[16/12/29 23:36:12] [debug] 正在上传媒体[xxx.mp4],当前进度:3/4
[16/12/29 23:36:13] [debug] 正在上传媒体[xxx.mp4],当前进度:4/4

另外,是否有兴趣成为这个项目的协作者(Collaborator)一起来完善这个项目

from mojo-weixin.

linux0ne avatar linux0ne commented on May 17, 2024

@KIDJourney
0x00、孩子,教教你:这叫——用户建议和反馈,不叫求。我的目的只有一个——让每个关注的项目都能更加的美好,尽自己所能去维护和丰富它。
0x01、你知道个6……你知道上面的内容是因为什么原因放在这里的?你知道它的目的是什么 ?你又知道谁建议放在这里的?不知不可怕,无知就太可怕了!
0x02、下次你再发言,请你就事论事。还有,再跟我说话,你客气点儿,别总尿叽的。我考虑够多,已经够给你留面儿了,懂吧!

from mojo-weixin.

lyrl avatar lyrl commented on May 17, 2024

。。。。 你直接用微信客户端多好

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

语音、小视频 已经支持
GIF动画、动画表情 开发中
网页链接 这个目前只能用文本的形式发送网页地址

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

GIF动画、动画表情 已经完成

from mojo-weixin.

linux0ne avatar linux0ne commented on May 17, 2024

@sjdy521
厉害! 加油!

from mojo-weixin.

wsdjeg avatar wsdjeg commented on May 17, 2024

@KIDJourney block

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

当前已经支持的 可以看下API.md里发送消息的部分,语音只能用文件的形式发送,图片、视频,其他文件也都支持发送

发自网易邮箱大师
在2016年10月16日 21:54,Wang Shidong 写道:

@KIDJourney block


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

from mojo-weixin.

wsdjeg avatar wsdjeg commented on May 17, 2024

@sjdy521 非常感谢,我刚刚接触这个项目,再多了解下。

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

@sjdy521 按照文档里面的发送视频:

#默认情况下,程序依靠文件扩展名或者url响应中的content-type等信息来识别媒体的格式,可能会导致识别不准确而影响发送
#这种情况下你可以传递一个hash的结构,手动指定媒体的相关信息
$client->send_media($friend|$group,{
    media_path => '/tmp/hello.txt', #媒体路径,可以是本地文件路径或者http协议的url
    media_data => 'hello world',    #可选,用于直接发送内存数据,优先级高于 media_path,
    media_mime => 'text/plain',     #可选,默认是 application/octet-stream,用于指定
    media_mtime => 1457169652 ,     #时间戳,文件修改时间,随意
    media_ext  => 'txt',            #文件扩展名
    media_size => 1024,             #可选,数据大小,默认会自动计算
    media_name => 'hello.txt',      #可选,媒体名称,默认是取文件名作为名称
});

这是我的代码:

                 $friend->send_media({
                    media_path => $commands[1],
                    media_mime => 'video/mpeg',
                    media_mtime => 1457169652 ,
                    media_ext  => 'mp4'
                  });

然后发送过去是文件,而不是直接可以看得视频。

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

把media_mime去掉试试?

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

==

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

我是根据mime里'video/mp4'来判断是视频文件,作为视频发送,你设置成了video/mpeg导致我会认为是普调文件,我已经在代码里兼容了 video/mpeg
你media_mime去掉的话,我会根据mp4的扩展名自动生成对应的media_mime,所以达到的效果是一样的
你可以先试试,基本上只需要设置media_path就行了,其他都可以不用管,会自动识别

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

哦,太好了,那我懂了。不过我这里老是502. 我回去用家里的网络试试。
[16/12/28 18:49:52] [warn] https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json 请求失败: 502 Bad Gateway
[16/12/28 18:49:52] [warn] media [ /tmp/7.mp4 ] upload failure

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

@sjdy521 , 我看到这个issue: liuwons/wxBot#99 说是微信上传文件的接口变了,由

https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json

变为了

https://file2.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json

请问这个链接在哪一个文件里面,我搜索不到,就不能替换测试.

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

一个kb级别的文件可以上传,但是2M的就不行了.

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

@csrgxtu 你说的这个issue很老了,官方的接口变更过一次,但本项目早就同步更新过了
文件不能上传可能是有大小限制,可以使用网页版手动测试确认下
上传文件的代码在这里 https://github.com/sjdy521/Mojo-Weixin/blob/master/lib/Mojo/Weixin/Message/Remote/_upload_media.pm

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

文件大小是7.2M,使用send_media上传会出现如下:
image
使用网页版传输视频文件如下:
image

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

@sjdy521 我看了webwx,接口使用的是一样的,但是它发送的将文件分片发送的,依次做了如下请求:

OPTIONS https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json 多次
POST https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json  多次
POST https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendvideomsg?fun=async&f=json

/webwxuploadmedia的请求头部如下:

Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4,zh-TW;q=0.2
Connection:keep-alive
Content-Length:526080
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryEULUqCcHOaa1IBCy
Host:file.wx2.qq.com
Origin:https://wx2.qq.com
Referer:https://wx2.qq.com/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

请问如何在下面代码中添加Content-Type

        $self->http_post(
            'https://file.' . $self->domain .'/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json',
            {json=>1,Referer=>'https://' . $self->domain . '/'},
            form=>{
                id=>'WU_FILE_0',
                name=>$msg->media_name,
                type=>$msg->media_mime,
                lastModifiedDate=>POSIX::strftime('%a %b %d %Y %H:%M:%S GMT+0800',gmtime($msg->media_mtime)),
                size=>$msg->media_size,
                mediatype=>(
                        $msg->media_type eq "image"                                             ?   "pic"
                    :   ($msg->media_type eq "video" or $msg->media_type eq "microvideo")       ?   "video"
                    :                                                                               "doc"
                ),
                uploadmediarequest=>$self->to_json($uploadmediarequest),
                webwx_data_ticket=>$self->search_cookie("webwx_data_ticket"),
                pass_ticket => $self->pass_ticket,
                filename =>{
                    content=>$msg->media_data,
                    filename=>$msg->media_name,
                    'Content-Type' => $msg->media_mime,
                },
            },
            sub{
                my $json = shift;
                if(not defined $json){
                    $self->warn("media [ ".$msg->media_path . " ] upload failure");
                }
                else{
                    $msg->media_id($json->{MediaId}) if $json->{MediaId};
                }
                $callback->($msg,$json);
            }
        );

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

多谢分析,我这边也确认上传文件变成多次分块上传了,我马上修复下

from mojo-weixin.

csrgxtu avatar csrgxtu commented on May 17, 2024

@sjdy521 worked, tks very much. btw,我怎样才能成为collaborator, 我想成为贡献者。

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

已经给你发邀请了 @csrgxtu

from mojo-weixin.

panzhc avatar panzhc commented on May 17, 2024

msg=$VAR1 = bless( {
'media_code' => 3,
'class' => 'recv',
'group_id' => '@@隐藏',
'time' => 1492424499,
'id' => '1559943971832219044',
'media_mtime' => 1492424502,
'media_size' => 0,
'media_ext' => 'html',
'media_name' => 'non-exist-path',
'format' => 'media',
'content' => '[图片]',
'media_type' => 'image',
'media_path' => 'non-exist-path',
'type' => 'group_message',
'media_mime' => 'text/html',
'media_data' => '',
'receiver_id' => '@隐藏',
'media_id' => '1559943971832219044:3',
'sender_id' => '@隐藏'
}, 'Mojo::Weixin::Message' );

path=$VAR1 = 'non-exist-path';
为什么有的图片会被识别成text/html? @sjdy521

from mojo-weixin.

hexsum avatar hexsum commented on May 17, 2024

获取媒体文件失败(失败的原因就是服务端返回了text/html类型)也导致保存到本地文件失败,路径变成non-exists-path,暂时无法确定是服务端原因还是我代码兼容性问题

from mojo-weixin.

panzhc avatar panzhc commented on May 17, 2024

谢谢回复,这个是间歇性的,有时候一天都正常,有时候又连续几个小时都non-exist-path,我再看下吧

from mojo-weixin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.