{"id":10006128,"date":"2022-08-08T06:17:10","date_gmt":"2022-08-07T22:17:10","guid":{"rendered":"https:\/\/ityet.com\/?p=10006128"},"modified":"2022-08-08T06:17:10","modified_gmt":"2022-08-07T22:17:10","slug":"go%e5%bc%80%e5%8f%91%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e7%ac%ac%e4%b8%89%e6%96%b9sdk%e6%8e%a8%e8%8d%90","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006128","title":{"rendered":"Go\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7b2c\u4e09\u65b9SDK\u63a8\u8350"},"content":{"rendered":"<blockquote><p>\u672c\u6587\u5df2\u6536\u5f55<a href=\"https:\/\/link.segmentfault.com\/?enc=J9sS6QFb4H6q4FNrAkPBNQ%3D%3D.0F8T0pTk%2B%2BAHfGjfAv9RJBLp4uQlp9W62LqBmlFlmJQAtnHJ%2B3mv2TSackGwhfoJ\" rel=\"nofollow\">\u7f16\u7a0b\u5b66\u4e60\u7b14\u8bb0<\/a>\u3002\u6db5\u76d6PHP\u3001JavaScript\u3001Linux\u3001Golang\u3001MySQL\u3001Redis\u548c\u5f00\u6e90\u5de5\u5177\u7b49\u7b49\u76f8\u5173\u5185\u5bb9\u3002<\/p><\/blockquote>\n<p>\u6700\u8fd1\u51c6\u5907\u7528Go\u8bed\u8a00\u5f00\u53d1\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\uff0c\u53d1\u73b0\u4f1a\u8c03\u7528\u5f88\u591a\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u670d\u52a1\u7aef\u63a5\u53e3\uff0c\u5e76\u4e14\u8fd8\u9700\u8981\u81ea\u5df1\u5c01\u88c5\u3002\u4e8e\u662f\u60f3\u7740\u53bbGitHub\u4e0a\u770b\u770b\uff0c\u662f\u5426\u6709\u7b2c\u4e09\u65b9\u73b0\u6210\u7684SDK\u76f4\u63a5\u62ff\u6765\u4f7f\u7528\uff0c\u7ed3\u679c\u53d1\u73b0\u4e24\u4e2a\u975e\u5e38\u4e0d\u9519\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u8fd9\u91cc\u5206\u4eab\u7ed9\u5927\u5bb6\u3002<\/p>\n<h2>SDK\u6807\u51c6<\/h2>\n<p>\u8fd9\u91cc\u7f57\u5217\u51e0\u70b9\uff0c\u4e2a\u4eba\u5728\u4f7f\u7528\u7b2c\u4e09\u65b9\u5f00\u6e90\u5e93\u7684\u4e00\u4e9b\u6807\u51c6\u7248\uff0c\u4f9b\u5927\u5bb6\u53c2\u8003\uff1a<\/p>\n<ol>\n<li>\u529f\u80fd\u7a33\u5b9a\uff0c\u6709\u4e0a\u751f\u4ea7\u73af\u5883\u7684\u6848\u4f8b\u3002\u907f\u514d\u51fa\u73b0SDK\u95ee\u9898\uff0c\u9700\u8981\u5f00\u53d1\u8005\u81ea\u5df1\u89e3\u51b3\u3002<\/li>\n<li>\u5f00\u53d1\u56e2\u961f\u7a33\u5b9a\uff0c\u6301\u7eed\u66f4\u65b0\u3002\u907f\u514d\u51fa\u73b0bug\u540e\u671f\u65e0\u4eba\u4fee\u590d\uff0c\u51fa\u73b0\u4e00\u79cd\u7c7b\u4f3cKPI\u7684\u5f00\u6e90\u9879\u76ee\u3002<\/li>\n<li>\u529f\u80fd\u8db3\u591f\u5f3a\u5927\u3002\u6bd5\u7adf\u662f\u4f7f\u7528\u5f00\u6e90SDK\uff0c\u5c31\u662f\u4e3a\u4e86\u51cf\u5c11\u81ea\u5df1\u53bb\u5f00\u53d1\u4e00\u4e9b\u989d\u5916\u7684\u529f\u80fd\uff0c\u628a\u5c3d\u529b\u66f4\u591a\u7684\u7528\u5728\u5b9e\u73b0\u4e1a\u52a1\u4e0a\u3002<\/li>\n<li>\u5b8c\u5584\u7684\u6587\u6863\u3002\u4e00\u4e2a\u518d\u597d\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u5982\u679c\u6ca1\u6709\u4e00\u4e2a\u5b8c\u5584\u7684\u6587\u6863\uff0c\u8fd9\u65e0\u7591\u7ed9\u4f7f\u7528\u8005\u589e\u52a0\u4e86\u4e00\u4e2a\u95e8\u69db\uff0c\u540c\u65f6\u4e5f\u964d\u4f4e\u4e86\u5f00\u53d1\u6548\u7387\uff0c\u8fbe\u4e0d\u5230\u76f4\u63a5\u4f7f\u7528\u7b2c\u4e09\u65b9SDK\u7684\u76ee\u7684\u3002<\/li>\n<\/ol>\n<h2>easywechat<\/h2>\n<p>\u7528PHP\u5f00\u53d1\u8fc7\u5fae\u4fe1\u751f\u6001\u7684\u4ea7\u54c1\uff0c\u4f30\u8ba1\u90fd\u77e5\u9053<a href=\"https:\/\/link.segmentfault.com\/?enc=bVFxF64IFyB%2ByjFx%2FAAczw%3D%3D.1HOR4OHFgbWxgxJi1Bv0Og0QZIb1qXKRjXQnOAFf4gI%3D\" rel=\"nofollow\">easywechat<\/a>\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u975e\u5b98\u65b9\u7684\u7b2c\u4e09\u65b9SDK\u3002\u529f\u80fd\u5f3a\u5927\u3001\u5b89\u88c5\u548c\u4f7f\u7528\u975e\u5e38\u7b80\u5355\uff0c\u56e0\u4e3a\u5b83\u662f\u4e00\u4e2a\u6807\u51c6\u7684 Composer \u5305\uff0c\u8fd9\u610f\u5473\u7740\u4efb\u4f55\u6ee1\u8db3\u4e0b\u5217\u5b89\u88c5\u6761\u4ef6\u7684 PHP \u9879\u76ee\u652f\u6301 Composer \u90fd\u53ef\u4ee5\u4f7f\u7528\u5b83\u3002\u76f4\u63a5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5b89\u88c5\u5c31\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u4e86\u3002<br \/><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042282249\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<pre><code class=\"php\">composer require overtrue\/wechat<\/code><\/pre>\n<h2>powerwechat<\/h2>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=I1YDgZVd0R4lUtUOOPodJA%3D%3D.aTinLiKRoR3XoHmGLNps6xYO4f0wF1be8B2TjT3kO4KVjSdIK5VMq5avKtySDrnG\" rel=\"nofollow\">PowerWeChat<\/a>\u662f\u4e00\u6b3e\u7b80\u5355\u6613\u7528\u7684WeChat SDK for Golang\u76ee\u524d\u5df2\u7ecf\u8986\u76d6\u5fae\u4fe1\u516c\u4f17\u53f7\u3001\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u3001\u5fae\u4fe1\u652f\u4ed8\u3001\u4f01\u4e1a\u5fae\u4fe1\u3002\u529f\u80fd\u975e\u5e38\u7684\u5f3a\u5927\uff0c\u51e0\u4e4e\u662f\u628a\u5fae\u4fe1\u751f\u6001\u7684\u4ea7\u54c1\u90fd\u5305\u542b\u5728\u5185\u3002\u5728\u9009\u62e9\u5b83\u4e3b\u8981\u57fa\u4e8e\u4e0b\u9762\u51e0\u4e2a\u76ee\u7684\uff1a<br \/><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042282250\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<ol>\n<li>\u529f\u80fd\u5f3a\u5927\uff0c\u5b8c\u6574\u7684\u5fae\u4fe1\u751f\u6001\u8986\u76d6\u3002\u6db5\u76d6\u4e86\u5fae\u4fe1\u516c\u4f17\u53f7\u3001\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u3001\u5fae\u4fe1\u4f01\u4e1a\u53f7\u548c\u5fae\u4fe1\u652f\u4ed8\u3002\u57fa\u672c\u6211\u4eec\u63a5\u89e6\u7684\u5fae\u4fe1\u5f00\u53d1\uff0c\u4e5f\u90fd\u662f\u8fd9\u51e0\u4e2a\u7c7b\u76ee\u3002\u6240\u4ee5\u8db3\u591f\u6211\u4eec\u4f7f\u7528\u4e86\u3002<\/li>\n<li>\u5f00\u53d1\u56e2\u961f\u7a33\u5b9a\u3002PowerWechat\u7531Artisan Cloud\u56e2\u961f\u6f5c\u5fc3\u7814\u53d1\u5e76\u4e14\u4e5f\u5728\u6301\u7eed\u66f4\u65b0\u548c\u5b8c\u5584\u5f53\u4e2d\u3002<\/li>\n<li>\n<p>\u5b8c\u5584\u7684\u6587\u6863\u3002PowerWechat\u6709\u5c5e\u4e8e\u81ea\u5df1\u7684\u5b98\u7f51\uff0c\u4e0d\u7ba1\u662f\u5fae\u4fe1\u516c\u4f17\u53f7\u3001\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u3001\u5fae\u4fe1\u4f01\u4e1a\u53f7\u548c\u5fae\u4fe1\u652f\u4ed8\u90fd\u6709\u72ec\u7acb\u7684\u6a21\u5757\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\uff0c\u540c\u65f6\u4e5f\u6709\u5b8c\u6574\u7684\u793a\u4f8b\u4ee3\u7801\u3002\u5982\u4e0b\u5fae\u4fe1\u4f01\u4e1a\u53f7\u5f00\u53d1\uff0c\u5982\u4f55\u914d\u7f6e\u6bcf\u4e00\u4e2a\u53c2\u6570\u5b9a\u4e49\u90fd\u6709\u5f88\u597d\u7684\u8bf4\u660e\u3002<\/p>\n<pre><code class=\"go\">package main\n\nimport (\n  &quot;log&quot;\n)\n\nfunc main() {\n  WeComApp, err := work.NewWork(&amp;work.UserConfig{\n CorpID:  &quot;app_id&quot;,       \/\/ \u4f01\u4e1a\u5fae\u4fe1\u7684app id\uff0c\u6240\u6709\u4f01\u4e1a\u5fae\u4fe1\u5171\u7528\u4e00\u4e2a\u3002\n AgentID: 100001,         \/\/ \u5185\u90e8\u5e94\u7528\u7684app id\n Secret:  &quot;wecom_secret&quot;, \/\/ \u5185\u90e8\u5e94\u7528\u7684app secret\n OAuth: work.OAuth{\n   Callback: &quot;https:\/\/wecom.artisan-cloud.com\/callback&quot;,\n   Scopes:   nil,\n },\n HttpDebug: true,\n  })\n  if err != nil {\n panic(err)\n  }\n  response := WeComApp.Base.GetCallbackIp()\n  log.Println(response)\n}<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>go-wechat-miniapp-sdk<\/h2>\n<p><a href=\"https:\/\/link.segmentfault.com\/?enc=NZyHxbYlK7BsVy2TFFuuuQ%3D%3D.3WKWtR0fbytxISNI6bxTGjsyzTLLXP6juA3G1WbfQS2ef2AY8HX%2Bxd0dINBOmoyFoxG7CFdw0dx79q%2Br3J%2BBlA%3D%3D\" rel=\"nofollow\">go-wechat-miniapp-sdk<\/a>\u57fa\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u76f8\u5173\u63a5\u53e3\u5c01\u88c5\uff0c\u4f7f\u7528golang\u8bed\u8a00\u5c01\u88c5\u7684\u4e00\u5957\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5b98\u65b9\u63a5\u53e3SDK\u3002\u652f\u6301\u5982\u4e0b\u529f\u80fd:<\/p>\n<ol>\n<li>\u767b\u5f55|\u7528\u6237\u4fe1\u606f<\/li>\n<li>\u8ba2\u9605\u6d88\u606f<\/li>\n<li>\u5ba2\u670d\u6d88\u606f<\/li>\n<li>\u7edf\u4e00\u670d\u52a1\u6d88\u606f<\/li>\n<li>\u83b7\u53d6\u5c0f\u7a0b\u5e8f\u7801<\/li>\n<li>&#8230;<\/li>\n<\/ol>\n<p>\u8be5SDK\u540c\u6837\u7684\uff0c\u4f7f\u7528\u8d77\u6765\u5f88\u7b80\u5355\uff0c\u4e5f\u80fd\u5f88\u5feb\u7684\u4e0a\u624b\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u8be5SDK\u5b89\u88c5\u65b9\u6cd5\u3002<\/p>\n<pre><code class=\"go\">go get github.com\/dgb8901\/go-wechat-miniapp-sdk<\/code><\/pre>\n<p>\u4e0b\u9762\u662f\u57fa\u7840\u4fe1\u606f\u914d\u7f6e\u3002<\/p>\n<pre><code>package helper\n\nimport (\n    &quot;github.com\/dgb8901\/go-wechat-miniapp-sdk\/config&quot;\n    &quot;github.com\/dgb8901\/go-wechat-miniapp-sdk\/service&quot;\n)\n\ntype wxaHelper struct {\n    wxaService *service.WxaService\n}\n\nvar helper = &amp;wxaHelper{}\n\nfunc Init() {\n\n    cfg := &amp;config.Cfg{\n        AppId:         &quot;AppId&quot;,\n        Secret:        &quot;Secret&quot;,\n        Token:         &quot;Token&quot;,\n        AesKey:        &quot;AesKey&quot;,\n        MsgDataFormat: &quot;DataFormat&quot;,\n    }\n    \/\/ wxaConfig := config.NewInRedis(cfg,&quot;127.0.0.1:6379&quot;,&quot;123456&quot;)\n    \/\/ wxaService := service.NewInRedis(redisConfig)\n    wxaConfig := config.NewInMemory(cfg)\n    wxaService := service.NewService(wxaConfig)\n\n    helper.wxaService = wxaService\n}\n\nfunc GetWxaService() *service.WxaService {\n    return wxaHelper.wxaService\n}<\/code><\/pre>\n<p>\u901a\u8fc7GitHub\u63d0\u4ea4\u7684\u8bb0\u5f55\uff0c\u53ef\u4ee5\u770b\u51fa\u8fd9\u4e2aSDK\u5e94\u8be5\u662f\u5c5e\u4e8e\u4e2a\u4eba\u5f00\u53d1\u3002\u6ca1\u6709\u5b8c\u6574\u7684\u6587\u6863\uff0c\u5e76\u4e14\u66f4\u65b0\u65f6\u95f4\u4e5f\u5f88\u4e45\u4e86\u3002\u4e0d\u63a8\u8350\u7528\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u5982\u679c\u4f60\u662f\u4e00\u4e2a\u60f3\u81ea\u5df1\u5b66\u4e60\u5982\u4f55\u53bb\u5c01\u88c5\uff0c\u6216\u8005\u60f3\u5728\u8fd9\u4e2a\u57fa\u7840\u4e0a\u53bb\u5b9e\u73b0\u4e00\u4e2a\u81ea\u5df1\u7684SDK\uff0c\u53ef\u4ee5\u501f\u9274\u4e00\u4e0b\u8be5SDK\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042282247\">https:\/\/segmentfault.com\/a\/1190000042282247<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5df2\u6536\u5f55\u7f16\u7a0b\u5b66\u4e60\u7b14\u8bb0\u3002\u6db5\u76d6PHP\u3001JavaScript\u3001Linux\u3001Golang\u3001MySQL\u3001Redis\u548c\u5f00 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006128","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006128"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006128\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}