elixir-wechat / Wechat
Licence: mit
Wechat API wrapper in Elixir
Stars: ✭ 70
Programming Languages
elixir
2628 projects
Projects that are alternatives of or similar to Wechat
Go Workwx
a sensible Work Weixin(企业微信, Wechat Work) SDK for Go
Stars: ✭ 181 (+158.57%)
Mutual labels: wechat-sdk, weixin-sdk, wechat, weixin
Werobot
WeRoBot 是一个微信公众号开发框架
Stars: ✭ 3,973 (+5575.71%)
Mutual labels: wechat-sdk, weixin-sdk, wechat, weixin
Python Weixin
微信(weixin|wechat) Python SDK 支持开放平台和公众平台 支持微信小程序云开发
Stars: ✭ 746 (+965.71%)
Mutual labels: wechat-sdk, weixin-sdk, wechat, weixin
Wechatpy
WeChat SDK for Python
Stars: ✭ 3,016 (+4208.57%)
Mutual labels: wechat-sdk, weixin-sdk, wechat, weixin
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+10040%)
Mutual labels: wechat-sdk, weixin-sdk, wechat, weixin
Weixin Popular
微信SDK JAVA (公众平台、开放平台、 商户平台、 服务商平台)
Stars: ✭ 2,384 (+3305.71%)
Mutual labels: weixin-sdk, wechat, weixin
Oss.clients.sns
社交网站sdk(标准库),微信公众号(订阅号,服务号,小程序)接口sdk-包含消息回复(明文和安全模式),Oauth2.0授权等
Stars: ✭ 136 (+94.29%)
Mutual labels: wechat-sdk, weixin-sdk, wechat
Weixin Java Cp Demo
基于Spring Boot 和 WxJava 实现的微信企业号/企业微信 后端Demo
Stars: ✭ 175 (+150%)
Mutual labels: wechat-sdk, wechat, weixin
go-wechat
💥weixin、wechat、微信公众平台、企业微信 golang/go sdk
Stars: ✭ 18 (-74.29%)
Mutual labels: weixin, wechat-sdk, weixin-sdk
Wechat
WeChat SDK for Go (微信SDK:简单、易用)
Stars: ✭ 3,144 (+4391.43%)
Mutual labels: wechat-sdk, wechat, weixin
Offiaccount
[微信公众号] A fast wechat offiaccount development sdk written in Golang
Stars: ✭ 68 (-2.86%)
Mutual labels: weixin-sdk, wechat, weixin
Fastbootweixin
基于Spring Boot的注解驱动式公众号极速开发框架,用注解重新定义公众号开发
Stars: ✭ 640 (+814.29%)
Mutual labels: wechat-sdk, weixin-sdk, weixin
Typescript Wxapi.d.ts
🦉微信小程序typescript的声明文件
Stars: ✭ 133 (+90%)
Mutual labels: weixin-sdk, wechat, weixin
wechat-sdk
微信登录支付sdk,支持小程序,APP登录,正在重构。QQ群:879729420
Stars: ✭ 73 (+4.29%)
Mutual labels: weixin, wechat-sdk, weixin-sdk
Weixin Java Miniapp Demo
基于Spring Boot 和 WxJava 实现的微信小程序Java后端Demo
Stars: ✭ 779 (+1012.86%)
Mutual labels: wechat-sdk, wechat, weixin
Weixin Sdk
微信公众平台(订阅号、服务号、企业号、小程序)、微信开放平台和微信支付 Java SDK
Stars: ✭ 933 (+1232.86%)
Mutual labels: wechat-sdk, weixin-sdk, weixin
Lxspider
爬虫案例合集。包括但不限于《淘宝、京东、天猫、豆瓣、抖音、快手、微博、微信、阿里、头条、pdd、优酷、爱奇艺、携程、12306、58、搜狐、百度指数、维普万方、Zlibraty、Oalib、小说、招标网、采购网、小红书》
Stars: ✭ 60 (-14.29%)
Mutual labels: wechat, weixin
Wechat API wrapper in Elixir.
Installation
def deps do
[{:wechat, "~> 0.4.0"}]
end
Configuration (optional)
config :wechat,
adapter_opts: {Wechat.Adapters.Redis, ["redis://localhost:6379/0"]},
httpoison_opts: [recv_timeout: 300_000]
Create a client to call APIs
iex(1)> client = Wechat.Client.new(appid: "WECHAT_APPID", secret: "WECHAT_SECRET")
%Wechat.Client{
appid: "WECHAT_APPID",
secret: "WECHAT_SECRET",
endpoint: "https://api.weixin.qq.com/"
}
iex(2)> Wechat.User.get(client)
{:ok,
%{
"count" => 1,
"data" => %{"openid" => ["oi00OuKAhA8bm5okpaIDs7WmUZr4"]},
"next_openid" => "oi00OuKAhA8bm5okpaIDs7WmUZr4",
"total" => 1
}}
Create a Wechat implementation
You can implement the Wechat
module to simplify the usage.
First, create an implementation by use Wechat
:
defmodule MyApp.Wechat do
use Wechat, otp_app: :my_app
def users do
client() |> Wechat.User.get()
end
end
Config the implementation with Wechat credentials:
config :my_app, MyApp.Wechat,
appid: "APP_ID",
secret: "APP_SECRET",
token: "TOKEN",
encoding_aes_key: "ENCODING_AES_KEY" # Required if you enabled the encrypt mode
Wechat implementation examples
JS-SDK
https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
<script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<%= raw MyApp.Wechat.wechat_config_js(@conn, debug: false, api: ~w(previewImage closeWindow)) %>
<script>
$(function() {
var urls = [];
$('img').map(function(){
url = window.location.origin + $(this).attr('src'),
urls.push(url);
});
$('img').click(function(e) {
wx.previewImage({
current: window.location.origin + $(this).attr('src'),
urls: urls
});
})
});
</script>
Process message in Phoenix
https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_standard_messages.html
- router.ex
defmodule MyApp.Router do
scope "/wechat", MyApp do
resources "/", WechatController, [:index, :create]
end
end
- wechat_controller.ex
defmodule MyApp.WechatController do
use MyApp.Web, :controller
# Validate signature param
plug Wechat.Plugs.RequestValidator, module: MyApp.Wechat
# Parse message
plug Wechat.Plugs.MessageParser, [module: MyApp.Wechat] when action in [:create]
def index(conn, %{"echostr" => echostr}) do
text conn, echostr
end
def create(conn, _params) do
%{"ToUserName" => to, "FromUserName" => from, "Content" => content} = conn.body_params
reply = %{from: to, to: from, content: content}
msg = Phoenix.View.render_to_string(EvercamWechatWeb.WechatView, "text.xml", reply: reply)
# Return encrypted message if possible
case Wechat.encrypt_message(msg) do
{:ok, reply} ->
render(conn, "encrypt.xml", reply: reply)
{:error, _} ->
text(conn, msg)
end
end
end
- text.xml.eex
<xml>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[<%= @reply.content %>]]></Content>
<ToUserName><![CDATA[<%= @reply.to %>]]></ToUserName>
<FromUserName><![CDATA[<%= @reply.from %>]]></FromUserName>
<CreateTime><%= DateTime.to_unix(DateTime.utc_now) %></CreateTime>
</xml>
- encrypt.xml.eex
<xml>
<Encrypt><![CDATA[<%= @reply.msg_encrypt %>]]></Encrypt>
<MsgSignature><![CDATA[<%= @reply.msg_signature %>]]></MsgSignature>
<TimeStamp><%= @reply.timestamp %></TimeStamp>
<Nonce><![CDATA[<%= @reply.nonce %>]]></Nonce>
</xml>
Users
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].