1 Star 0 Fork 34

tkggusraqk / weixinHttpApi2.0

forked from codeman35 / weixinHttpApi2.0 
Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
MainForm_11_SENDFILE.cs 1.58 KB
Copy Edit Web IDE Raw Blame History
codeman35 authored 2016-01-13 08:26 . no commit message
using HttpSocket;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace demo_win_httpsocket
{
partial class MainForm
{
void _11_SENDFILE(string userid,string filename)
{
_ShowMessage(System.Reflection.MethodInfo.GetCurrentMethod().Name);
var MediaId = _17_WEBWXUPLOADMEDIA(filename);
var type = MimeMapping.GetMimeMappingByFile(filename).ToLower();
//if(type.StartsWith("audio/"))
//{
//}
if (type.StartsWith("image/"))
{
//发送图片
_15_WEBWXSENDEMOTICON(userid, UserName, MediaId, 47);
}
else
{
var Message = "<appmsg appid='" + WEB["APPID"] + "' sdkver=''><title>{filename}</title><des></des><action></action><type>6</type><content></content><url></url><lowurl></lowurl><appattach><totallen>{filelength}</totallen><attachid>{attachid}</attachid><fileext>{filetype}</fileext></appattach><extinfo></extinfo></appmsg>";
Message = Message.Replace("{attachid}", MediaId);
Message = Message.Replace("{filename}", Path.GetFileName(filename));
Message = Message.Replace("{filelength}", "" + File.ReadAllBytes(filename).Length);
Message = Message.Replace("{filetype}", Path.GetExtension(filename).TrimStart(new char[] { '.' }));
_16_WEBWXSENDAPPMSG(userid, UserName, Message, 6);
}
}
}
}

Comment ( 0 )

Sign in for post a comment

1
https://gitee.com/tkggusraqk/weixinHttpApi2.0.git
git@gitee.com:tkggusraqk/weixinHttpApi2.0.git
tkggusraqk
weixinHttpApi2.0
weixinHttpApi2.0
master

Search