|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992 |
- # ![title](title.png)
-
- ## `注意` ⚠️
-
- - [v1 版本入口](https://github.com/medivhzhan/weapp/tree/v1)
- - 新版本暂时不包含支付相关内容, 已有很多优秀的支付相关模块;
- - 为了保证大家及时用上新功能,已发布 v2 版本,请大家使用经过`线上测试` ✅ 的接口。
- - 未完成的接口将在经过线上测试后在新版本中提供给大家。
- - 大部分接口需要去线上测试。最近一直比较忙,有条件的朋友可以帮忙一起测试,我代表所有使用者谢谢你: )
- - 欢迎大家一起完善 :)
-
- ## 获取代码
-
- ```sh
-
- go get -u github.com/medivhzhan/weapp/v2
-
- ```
-
- ## `目录`
-
- > 文档按照[小程序服务端官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/)排版,方便您一一对照查找相关内容。
-
- ✅: 代表已经通过线上测试
- ⚠️: 代表还没有或者未完成
-
- - [登录](#登录)
- - [code2Session](#code2Session) ✅
- - [用户信息](#用户信息)
- - [getPaidUnionId](#getPaidUnionId) ✅
- - [接口调用凭证](#接口调用凭证)
- - [getAccessToken](#getAccessToken) ✅
- - [数据分析](#数据分析)
- - [访问留存](#访问留存)
- - [getDailyRetain](#getDailyRetain) ✅
- - [getWeeklyRetain](#getWeeklyRetain) ✅
- - [getMonthlyRetain](#getMonthlyRetain) ✅
- - [getDailySummary](#getDailySummary) ✅
- - [访问趋势](#访问趋势)
- - [getDailyVisitTrend](#getDailyVisitTrend) ✅
- - [getWeeklyVisitTrend](#getWeeklyVisitTrend) ✅
- - [getMonthlyVisitTrend](#getMonthlyVisitTrend) ✅
- - [getUserPortrait](#getUserPortrait) ✅
- - [getVisitDistribution](#getVisitDistribution) ✅
- - [getVisitPage](#getVisitPage) ✅
- - [客服消息](#客服消息)
- - [getTempMedia](#getTempMedia) ✅
- - [sendCustomerServiceMessage](#sendCustomerServiceMessage) ✅
- - [setTyping](#setTyping) ✅
- - [uploadTempMedia](#uploadTempMedia) ✅
- - [统一服务消息](#统一服务消息)
- - [sendUniformMessage](#sendUniformMessage) ✅
- - [动态消息](#动态消息)
- - [createActivityId](#createActivityId)
- - [setUpdatableMsg](#setUpdatableMsg)
- - [插件管理](#插件管理)
- - [applyPlugin](#applyPlugin)
- - [getPluginDevApplyList](#getPluginDevApplyList)
- - [getPluginList](#getPluginList)
- - [setDevPluginApplyStatus](#setDevPluginApplyStatus)
- - [unbindPlugin](#unbindPlugin)
- - [附近的小程序](#附近的小程序)
- - [addNearbyPoi](#addNearbyPoi)
- - [deleteNearbyPoi](#deleteNearbyPoi)
- - [getNearbyPoiList](#getNearbyPoiList)
- - [setNearbyPoiShowStatus](#setNearbyPoiShowStatus)
- - [小程序码](#小程序码) ✅
- - [createQRCode](#createQRCode) ✅
- - [get](#get) ✅
- - [getUnlimited](#getUnlimited) ✅
- - [内容安全](#内容安全)
- - [imgSecCheck](#imgSecCheck) ✅
- - [mediaCheckAsync](#mediaCheckAsync)✅
- - [msgSecCheck](#msgSecCheck) ✅
- - [图像处理](#图像处理)
- - [aiCrop](#aiCrop) ✅
- - [scanQRCode](#scanQRCode) ✅
- - [superResolution](#superResolution)
- - [及时配送](#及时配送) ⚠️
- - [小程序使用](#小程序使用)
- - [abnormalConfirm](#abnormalConfirm)
- - [addDeliveryOrder](#addDeliveryOrder)
- - [addDeliveryTip](#addDeliveryTip)
- - [cancelDeliveryOrder](#cancelDeliveryOrder)
- - [getAllImmediateDelivery](#getAllImmediateDelivery)
- - [getBindAccount](#getBindAccount)
- - [getDeliveryOrder](#getDeliveryOrder)
- - [mockUpdateDeliveryOrder](#mockUpdateDeliveryOrder)
- - [onDeliveryOrderStatus](#onDeliveryOrderStatus)
- - [preAddDeliveryOrder](#preAddDeliveryOrder)
- - [preCancelDeliveryOrder](#preCancelDeliveryOrder)
- - [reDeliveryOrder](#reDeliveryOrder)
- - [服务提供方使用](#服务提供方使用)
- - [updateDeliveryOrder](#updateDeliveryOrder)
- - [onAgentPosQuery](#onAgentPosQuery)
- - [onAuthInfoGet](#onAuthInfoGet)
- - [onCancelAuth](#onCancelAuth)
- - [onDeliveryOrderAdd](#onDeliveryOrderAdd)
- - [onDeliveryOrderAddTips](#onDeliveryOrderAddTips)
- - [onDeliveryOrderCancel](#onDeliveryOrderCancel)
- - [onDeliveryOrderConfirmReturn](#onDeliveryOrderConfirmReturn)
- - [onDeliveryOrderPreAdd](#onDeliveryOrderPreAdd)
- - [onDeliveryOrderPreCancel](#onDeliveryOrderPreCancel)
- - [onDeliveryOrderQuery](#onDeliveryOrderQuery)
- - [onDeliveryOrderReAdd](#onDeliveryOrderReAdd)
- - [onPreAuthCodeGet](#onPreAuthCodeGet)
- - [onRiderScoreSet](#onRiderScoreSet)
- - [物流助手](#物流助手) ⚠️
- - [小程序使用](#小程序使用)
- - [addExpressOrder](#addExpressOrder)
- - [cancelExpressOrder](#cancelExpressOrder)
- - [getAllDelivery](#getAllDelivery)
- - [getExpressOrder](#getExpressOrder)
- - [getExpressPath](#getExpressPath)
- - [getExpressPrinter](#getExpressPrinter)
- - [getExpressQuota](#getExpressQuota)
- - [onExpressPathUpdate](#onExpressPathUpdate)
- - [testUpdateExpressOrder](#testUpdateExpressOrder)
- - [updateExpressPrinter](#updateExpressPrinter)
- - [服务提供方使用](#服务提供方使用)
- - [getExpressContact](#getExpressContact)
- - [onAddExpressOrder](#onAddExpressOrder)
- - [onCancelExpressOrder](#onCancelExpressOrder)
- - [onCheckExpressBusiness](#onCheckExpressBusiness)
- - [onGetExpressQuota](#onGetExpressQuota)
- - [previewExpressTemplate](#previewExpressTemplate)
- - [updateExpressBusiness](#updateExpressBusiness)
- - [updateExpressPath](#updateExpressPath)
- - [OCR](#OCR)
- - [bankcard](#bankcard) ✅
- - [businessLicense](#businessLicense) ✅
- - [driverLicense](#driverLicense) ✅
- - [idcard](#idcard) ✅
- - [printedText](#printedText) ✅
- - [vehicleLicense](#vehicleLicense) ✅
- - [运维中心](#运维中心) ⚠️
- - [realTimeLogSearch](#realTimeLogSearch)
- - [小程序搜索](#小程序搜索) ⚠️
- - [siteSearch](#siteSearch)
- - [submitPages](#submitPages)
- - [生物认证](#生物认证)
- - [verifySignature](#verifySignature)
- - [订阅消息](#订阅消息) ✅
- - [addTemplate](#addTemplate) ✅
- - [deleteTemplate](#deleteTemplate) ✅
- - [getCategory](#getCategory) ✅
- - [getPubTemplateKeyWordsById](#getPubTemplateKeyWordsById)✅
- - [getPubTemplateTitleList](#getPubTemplateTitleList) ✅
- - [getTemplateList](#getTemplateList) ✅
- - [sendSubscribeMessage](#sendSubscribeMessage) ✅
- - [解密](#解密)
- - [解密手机号码](#解密手机号码) ✅
- - [解密分享内容](#解密分享内容)
- - [解密用户信息](#解密用户信息) ✅
- - [解密微信运动](#解密微信运动)
- - [人脸识别](#人脸识别)
-
- ---
-
- ## 登录
-
- ### code2Session
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.Login("appid", "secret", "code")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 用户信息
-
- ### getPaidUnionId
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.getPaidUnionId.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetPaidUnionID("access-token", "open-id", "transaction-id")
- // 或者
- res, err := weapp.GetPaidUnionIDWithMCH("access-token", "open-id", "out-trade-number", "mch-id")
-
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 接口调用凭证
-
- ### getAccessToken
-
- > 调用次数有限制 请注意缓存
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetAccessToken("appid", "secret")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 数据分析
-
- ### 访问留存
-
- #### getDailyRetain
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/visit-retain/analysis.getDailyRetain.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetDailyRetain("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getWeeklyRetain
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/visit-retain/analysis.getWeeklyRetain.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetWeeklyRetain("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getMonthlyRetain
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/visit-retain/analysis.getMonthlyRetain.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetMonthlyRetain("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### getDailySummary
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/analysis.getDailySummary.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetDailySummary("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### 访问趋势
-
- #### getDailyVisitTrend
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/visit-trend/analysis.getDailyVisitTrend.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetDailyVisitTrend("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getWeeklyVisitTrend
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/visit-trend/analysis.getWeeklyVisitTrend.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetWeeklyVisitTrend("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getMonthlyVisitTrend
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/visit-trend/analysis.getMonthlyVisitTrend.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetMonthlyVisitTrend("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### getUserPortrait
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/analysis.getUserPortrait.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetUserPortrait("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### getVisitDistribution
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/analysis.getVisitDistribution.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetVisitDistribution("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### getVisitPage
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/data-analysis/analysis.getVisitPage.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetVisitPage("access-token", "begin-date", "end-date")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 客服消息
-
- ### getTempMedia
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.getTempMedia.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- resp, res, err := weapp.GetTempMedia("access-token", "media-id")
- if err != nil {
- // 处理一般错误信息
- return
- }
- defer resp.Close()
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### sendCustomerServiceMessage
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.send.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- // 接收并处理异步结果
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- // 文本消息
- srv.OnCustomerServiceTextMessage(func(msg *weapp.TextMessageResult) *weapp.TransferCustomerMessage {
-
- reply := weapp.CSMsgText{
- Content: "content",
- }
-
- res, err := reply.SendTo("open-id", "access-token")
- if err != nil {
- // 处理一般错误信息
- return nil
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return nil
- }
-
- return nil
- })
-
- // 图片消息
- srv.OnCustomerServiceImageMessage(func(msg *weapp.TextMessageResult) *weapp.TransferCustomerMessage {
-
- reply := weapp.CSMsgImage{
- MediaID: "media-id",
- }
-
- res, err := reply.SendTo("open-id", "access-token")
- if err != nil {
- // 处理一般错误信息
- return nil
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return nil
- }
-
- return nil
- })
-
- // 小程序卡片消息
- srv.OnCustomerServiceCardMessage(func(msg *weapp.TextMessageResult) *weapp.TransferCustomerMessage {
-
- reply := weapp.CSMsgMPCard{
- Title: "title",
- PagePath: "page-path",
- ThumbMediaID: "thumb-media-id",
- }
- res, err := reply.SendTo("open-id", "access-token")
- if err != nil {
- // 处理一般错误信息
- return nil
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return nil
- }
-
- return nil
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- ### setTyping
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.setTyping.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.SetTyping("access-token", "open-id", weapp.SetTypingCommandTyping)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### uploadTempMedia
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/customer-message/customerServiceMessage.uploadTempMedia.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.UploadTempMedia("access-token", weapp.TempMediaTypeImage, "media-filename")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 统一服务消息
-
- ### sendUniformMessage
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/uniform-message/uniformMessage.send.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- sender := weapp.UniformMsgSender{
- ToUser: "open-id",
- UniformWeappTmpMsg: weapp.UniformWeappTmpMsg{
- TemplateID: "template-id",
- Page: "page",
- FormID: "form-id",
- Data: weapp.UniformMsgData{
- "keyword": {Value: "value"},
- },
- EmphasisKeyword: "keyword.DATA",
- },
- UniformMpTmpMsg: weapp.UniformMpTmpMsg{
- AppID: "app-id",
- TemplateID: "template-id",
- URL: "url",
- Miniprogram: weapp.UniformMsgMiniprogram{"miniprogram-app-id", "page-path"},
- Data: weapp.UniformMsgData{
- "keyword": {"value", "color"},
- },
- },
- }
-
- res, err := sender.Send("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 动态消息
-
- ### createActivityId
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/updatable-message/updatableMessage.createActivityId.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.CreateActivityId("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### setUpdatableMsg
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/updatable-message/updatableMessage.setUpdatableMsg.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
-
- setter := weapp.UpdatableMsgSetter{
- "activity-id",
- UpdatableMsgJoining,
- UpdatableMsgTempInfo{
- []UpdatableMsgParameter{
- {UpdatableMsgParamMemberCount, "parameter-value-number"},
- {UpdatableMsgParamRoomLimit, "parameter-value-number"},
- },
- },
- }
-
- res, err := setter.Set("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 插件管理
-
- ### applyPlugin
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/plugin-management/pluginManager.applyPlugin.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.ApplyPlugin("access-token", "plugin-app-id", "reason")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### getPluginDevApplyList
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/plugin-management/pluginManager.getPluginDevApplyList.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetPluginDevApplyList("access-token", 1, 2)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### getPluginList
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/plugin-management/pluginManager.getPluginList.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetPluginList("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### setDevPluginApplyStatus
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/plugin-management/pluginManager.setDevPluginApplyStatus.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.SetDevPluginApplyStatus("access-token", "plugin-app-id", "reason", weapp.DevAgree)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### unbindPlugin
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/plugin-management/pluginManager.unbindPlugin.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.UnbindPlugin("access-token", "plugin-app-id")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 附近的小程序
-
- ### addNearbyPoi
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/nearby-poi/nearbyPoi.add.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- poi := NearbyPoi{
- PicList: PicList{[]string{"first-picture-url", "second-picture-url", "third-picture-url"}},
- ServiceInfos: weapp.ServiceInfos{[]weapp.ServiceInfo{
- {1, 1, "name", "app-id", "path"},
- }},
- StoreName: "store-name",
- Hour: "11:11-12:12",
- Credential: "credential",
- Address: "address", // 地址 必填
- CompanyName: "company-name", // 主体名字 必填
- QualificationList: "qualification-list", // 证明材料 必填 如果company_name和该小程序主体不一致,需要填qualification_list,详细规则见附近的小程序使用指南-如何证明门店的经营主体跟公众号或小程序帐号主体相关http://kf.qq.com/faq/170401MbUnim17040122m2qY.html
- KFInfo: weapp.KFInfo{true, "kf-head-img", "kf-name"}, // 客服信息 选填,可自定义服务头像与昵称,具体填写字段见下方示例kf_info pic_list是字符串,内容是一个json!
- PoiID: "poi-id", // 如果创建新的门店,poi_id字段为空 如果更新门店,poi_id参数则填对应门店的poi_id 选填
- }
-
- res, err := poi.Add("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnAddNearbyPoi(func(mix *weapp.AddNearbyPoiResult) {
- // 处理返回结果
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- ### deleteNearbyPoi
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/nearby-poi/nearbyPoi.delete.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.DeleteNearbyPoi("access-token", "poi-id")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### getNearbyPoiList
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/nearby-poi/nearbyPoi.getList.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetNearbyPoiList("access-token", 1, 10)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### setNearbyPoiShowStatus
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/nearby-poi/nearbyPoi.setShowStatus.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.SetNearbyPoiShowStatus("access-token", "poi-id", weapp.ShowNearbyPoi)
- // 或者
- res, err := weapp.SetNearbyPoiShowStatus("access-token", "poi-id", weapp.HideNearbyPoi)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 小程序码
-
- ### createQRCode
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.createQRCode.html)
-
- ```go
-
- import (
- "ioutil"
- "github.com/medivhzhan/weapp/v2"
- )
-
-
- creator := weapp.QRCodeCreator{
- Path: "mock/path",
- Width: 430,
- }
-
- resp, res, err := creator.Create("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- defer resp.Body.Close()
-
- content, err := ioutil.ReadAll(resp.Body)
- // 处理图片内容
-
- ```
-
- ### get
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.get.html)
-
- ```go
-
- import (
- "ioutil"
- "github.com/medivhzhan/weapp/v2"
- )
-
-
- getter := weapp.QRCode{
- Path: "mock/path",
- Width: 430,
- AutoColor: true,
- LineColor: weapp.Color{"r", "g", "b"},
- IsHyaline: true,
- }
-
- resp, res, err := getter.Get("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- defer resp.Body.Close()
-
- content, err := ioutil.ReadAll(resp.Body)
- // 处理图片内容
-
- ```
-
- ### getUnlimited
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html)
-
- ```go
-
- import (
- "ioutil"
- "github.com/medivhzhan/weapp/v2"
- )
-
-
- getter := weapp.UnlimitedQRCode{
- Scene: "scene-data",
- Page: "mock/page",
- Width: 430,
- AutoColor: true,
- LineColor: weapp.Color{"r", "g", "b"},
- IsHyaline: true,
- }
-
- resp, res, err := getter.Get("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- defer resp.Body.Close()
-
- content, err := ioutil.ReadAll(resp.Body)
- // 处理图片内容
-
- ```
-
- ---
-
- ## 内容安全
-
- ### imgSecCheck
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.imgSecCheck.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.IMGSecCheck("access-token", "local-filename")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### mediaCheckAsync
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.mediaCheckAsync.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.MediaCheckAsync("access-token", "image-url", weapp.MediaTypeImage)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- // 接收并处理异步结果
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnMediaCheckAsync(func(mix *weapp.MediaCheckAsyncResult) {
- // 处理返回结果
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- ### msgSecCheck
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.MSGSecCheck("access-token", "message-content")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 图像处理
-
- ### aiCrop
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/img/img.aiCrop.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.AICrop("access-token", "filename")
- // 或者
- res, err := weapp.AICropByURL("access-token", "url")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### scanQRCode
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/img/img.scanQRCode.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.ScanQRCode("access-token", "file-path")
- // 或者
- res, err := weapp.ScanQRCodeByURL("access-token", "qr-code-url")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### superResolution
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/img/img.superresolution.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.SuperResolution("access-token", "file-path")
- // 或者
- res, err := weapp.SuperResolutionByURL("access-token", "img-url")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 及时配送
-
- ### 服务提供方使用
-
- #### updateDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.updateOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- mocker := weapp.DeliveryOrderUpdater{
- // ...
- }
-
- res, err := mocker.Update("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### onAgentPosQuery
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onAgentPosQuery.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnAgentPosQuery(func(mix *weapp.AgentPosQueryResult) *weapp.AgentPosQueryReturn {
- // 处理返回结果
-
- return &weapp.AgentPosQueryReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onAuthInfoGet
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onAuthInfoGet.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnAuthInfoGet(func(mix *weapp.AuthInfoGetResult) *weapp.AuthInfoGetReturn {
- // 处理返回结果
-
- return &weapp.AuthInfoGetReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onCancelAuth
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onCancelAuth.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnCancelAuth(func(mix *weapp.CancelAuthResult) *weapp.CancelAuthReturn {
- // 处理返回结果
-
- return &weapp.CancelAuthReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderAdd
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderAdd.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderAdd(func(mix *weapp.DeliveryOrderAddResult) *weapp.DeliveryOrderAddReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderAddReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderAddTips
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderAddTips.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderAddTips(func(mix *weapp.DeliveryOrderAddTipsResult) *weapp.DeliveryOrderAddTipsReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderAddTipsReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderCancel
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderCancel.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderCancel(func(mix *weapp.DeliveryOrderCancelResult) *weapp.DeliveryOrderCancelReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderCancelReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderConfirmReturn
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderConfirmReturn.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderReturnConfirm(func(mix *weapp.DeliveryOrderReturnConfirmResult) *weapp.DeliveryOrderReturnConfirmReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderReturnConfirmReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderPreAdd
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderPreAdd.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderPreAdd(func(mix *weapp.DeliveryOrderPreAddResult) *weapp.DeliveryOrderPreAddReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderPreAddReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderPreCancel
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderPreCancel.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderPreCancel(func(mix *weapp.DeliveryOrderPreCancelResult) *weapp.DeliveryOrderPreCancelReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderPreCancelReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderQuery
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderQuery.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderQuery(func(mix *weapp.DeliveryOrderQueryResult) *weapp.DeliveryOrderQueryReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderQueryReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onDeliveryOrderReAdd
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onOrderReAdd.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderReadd(func(mix *weapp.DeliveryOrderReaddResult) *weapp.DeliveryOrderReaddReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderReaddReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onPreAuthCodeGet
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onPreAuthCodeGet.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnPreAuthCodeGet(func(mix *weapp.PreAuthCodeGetResult) *weapp.PreAuthCodeGetReturn {
- // 处理返回结果
-
- return &weapp.PreAuthCodeGetReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onRiderScoreSet
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-provider/immediateDelivery.onRiderScoreSet.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnRiderScoreSet(func(mix *weapp.RiderScoreSetResult) *weapp.RiderScoreSetReturn {
- // 处理返回结果
-
- return &weapp.PreAuthCodeGetReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- ### 小程序使用
-
- #### abnormalConfirm
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.abnormalConfirm.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- confirmer := weapp.AbnormalConfirmer{
- ShopID: "123456",
- ShopOrderID: "123456",
- ShopNo: "shop_no_111",
- WaybillID: "123456",
- Remark: "remark",
- DeliverySign: "123456",
- }
-
- res, err := confirmer.Confirm("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### addDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.addOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- creator := weapp.DeliveryOrderCreator{
- // ...
- }
-
- res, err := creator.Create("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### addDeliveryTip
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.addTip.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- adder := weapp.DeliveryTipAdder{
- // ...
- }
-
- res, err := adder.Add("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### cancelDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.cancelOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- canceler := weapp.DeliveryOrderCanceler{
- // ...
- }
-
- res, err := canceler.Cancel("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getAllImmediateDelivery
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getAllImmeDelivery.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetAllImmediateDelivery("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getBindAccount
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getBindAccount.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetBindAccount("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.getOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- getter := weapp.DeliveryOrderGetter{
- // ...
- }
-
- res, err := getter.Get("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### mockUpdateDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.mockUpdateOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- mocker := weapp.UpdateDeliveryOrderMocker{
- // ...
- }
-
- res, err := mocker.Mock("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### onDeliveryOrderStatus
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.onOrderStatus.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnDeliveryOrderStatusUpdate(func(mix *weapp.DeliveryOrderStatusUpdateResult) *weapp.DeliveryOrderStatusUpdateReturn {
- // 处理返回结果
-
- return &weapp.DeliveryOrderStatusUpdateReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### preAddDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.preAddOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- creator := weapp.DeliveryOrderCreator{
- // ...
- }
-
- res, err := creator.Prepare("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### preCancelDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.preCancelOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- canceler := weapp.DeliveryOrderCanceler{
- // ...
- }
-
- res, err := canceler.Prepare("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### reDeliveryOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/immediate-delivery/by-business/immediateDelivery.reOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- creator := weapp.DeliveryOrderCreator{
- // ...
- }
-
- res, err := creator.Recreate("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 物流助手
-
- ### 小程序使用
-
- #### addExpressOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.addOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- creator := weapp.ExpressOrderCreator{
- // ...
- }
-
- res, err := creator.Create("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### cancelExpressOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.cancelOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- canceler := weapp.ExpressOrderCanceler{
- // ...
- }
-
- res, err := canceler.cancel("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getAllDelivery
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.getAllDelivery.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.getAllDelivery("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getExpressOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.getOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- getter := weapp.ExpressOrderGetter{
- // ...
- }
-
- res, err := getter.Get("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getExpressPath
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.getPath.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- getter := weapp.ExpressPathGetter{
- // ...
- }
-
- res, err := getter.Get("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getExpressPrinter
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.getPrinter.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetPrinter("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### getExpressQuota
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.getQuota.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- getter := weapp.QuotaGetter{
- // ...
- }
-
- res, err := getter.Get("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### onExpressPathUpdate
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.onPathUpdate.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnExpressPathUpdate(func(mix *weapp.ExpressPathUpdateResult) {
- // 处理返回结果
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### testUpdateExpressOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.testUpdateOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- tester := weapp.UpdateExpressOrderTester{
- // ...
- }
-
- res, err := tester.Test("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### updateExpressPrinter
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.updatePrinter.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- updater := weapp.PrinterUpdater{
- // ...
- }
-
- res, err := updater.Update("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### 服务提供方使用
-
- #### getExpressContact
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.getContact.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.GetContact("access-token", "token", "wat-bill-id")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### onAddExpressOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.onAddOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnAddExpressOrder(func(mix *weapp.AddExpressOrderResult) *weapp.AddExpressOrderReturn {
- // 处理返回结果
-
- return &weapp.AddExpressOrderReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onCancelExpressOrder
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.onCancelOrder.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnCancelExpressOrder(func(mix *weapp.CancelExpressOrderResult) *weapp.CancelExpressOrderReturn {
- // 处理返回结果
-
- return &weapp.CancelExpressOrderReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onCheckExpressBusiness
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.onCheckBusiness.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnCheckExpressBusiness(func(mix *weapp.CheckExpressBusinessResult) *weapp.CheckExpressBusinessReturn {
- // 处理返回结果
-
- return &weapp.CheckExpressBusinessReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### onGetExpressQuota
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.onGetQuota.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- srv, err := weapp.NewServer("app-id", "token", "aes-key", "mch-id", "api-key", true)
- if err != nil {
- // 处理微信返回错误信息
- return
- }
-
- srv.OnGetExpressQuota(func(mix *weapp.GetExpressQuotaResult) *weapp.GetExpressQuotaReturn {
- // 处理返回结果
-
- return &weapp.GetExpressQuotaReturn{
- // ...
- }
- })
-
- if err := srv.Serve(http.ResponseWriter, *http.Request); err != nil {
- // 处理微信返回错误信息
- return
- }
-
- ```
-
- #### previewExpressTemplate
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.previewTemplate.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- previewer := weapp.ExpressTemplatePreviewer{
- // ...
- }
-
- res, err := previewer.Preview("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### updateExpressBusiness
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.updateBusiness.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- updater := weapp.BusinessUpdater{
- // ...
- }
-
- res, err := updater.Update("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- #### updateExpressPath
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-provider/logistics.updatePath.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- updater := weapp.ExpressPathUpdater{
- // ...
- }
-
- res, err := updater.Update("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## OCR
-
- ### bankcard
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/ocr/ocr.bankcard.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.BankCard("access-token", "file-path", weapp.RecognizeModeScan)
- // 或者
- res, err := weapp.BankCardByURL("access-token", "card-url", weapp.RecognizeModePhoto)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### businessLicense
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/ocr/ocr.businessLicense.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.BusinessLicense("access-token", "file-path")
- // 或者
- res, err := weapp.BusinessLicenseByURL("access-token", "card-url")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### driverLicense
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/ocr/ocr.driverLicense.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.DriverLicense("access-token", "file-path")
- // 或者
- res, err := weapp.DriverLicenseByURL("access-token", "card-url")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### idcard
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/ocr/ocr.idcard.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.IDCardByURL("access-token", "card-url", weapp.RecognizeModePhoto)
- // 或者
- res, err := weapp.IDCard("access-token", "file-path", weapp.RecognizeModeScan)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### printedText
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/ocr/ocr.printedText.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.PrintedText("access-token", "file-path")
- // 或者
- res, err := weapp.PrintedTextByURL("access-token", "card-url")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ### vehicleLicense
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/ocr/ocr.vehicleLicense.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.VehicleLicense("access-token", "file-path", weapp.RecognizeModeScan)
- // 或者
- res, err := weapp.VehicleLicenseByURL("access-token", "card-url", weapp.RecognizeModePhoto)
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 小程序搜索
-
- ### siteSearch
-
- ### submitPages
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/search/search.submitPages.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- sender := weapp.SearchSubmitPages{
- []weapp.SearchSubmitPage{
- {
- Path: "pages/index/index",
- Query: "id=test",
- },
- },
- }
-
- res, err := sender.Send("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 生物认证
-
- ### verifySignature
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/soter/soter.verifySignature.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.VerifySignature("access-token", "open-id", "data", "signature")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 订阅消息
-
- ### addTemplate
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.addTemplate.html)
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- // AddTemplate 组合模板并添加至帐号下的个人模板库
- //
- // token 微信 access_token
- // tid 模板ID
- // desc 服务场景描述,15个字以内
- // keywordIDList 关键词 ID 列表
- res, err := weapp.AddTemplate("access_token", "tid", "desc", []int32{1, 2, 3})
- if err != nil {
- // 处理一般错误信息
- return
- }
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### deleteTemplate
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.deleteTemplate.html)
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- // DeleteTemplate 删除帐号下的某个模板
- //
- // token 微信 access_token
- // pid 模板ID
- res, err := weapp.DeleteTemplate("access_token", "pid")
- if err != nil {
- // 处理一般错误信息
- return
- }
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### getCategory
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getCategory.html)
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- // GetTemplateCategory 删除帐号下的某个模板
- //
- // token 微信 access_token
- res, err := weapp.GetTemplateCategory("access_token")
- if err != nil {
- // 处理一般错误信息
- return
- }
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### getPubTemplateKeyWordsById
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getPubTemplateKeyWordsById.html)
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- // GetPubTemplateKeyWordsById 获取模板标题下的关键词列表
- //
- // token 微信 access_token
- // tid 模板ID
- res, err := weapp.GetPubTemplateKeyWordsById("access_token", "tid")
- if err != nil {
- // 处理一般错误信息
- return
- }
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### getPubTemplateTitleList
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getPubTemplateTitleList.html)
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- // GetPubTemplateTitleList 获取帐号所属类目下的公共模板标题
- //
- // token 微信 access_token
- // ids 类目 id,多个用逗号隔开
- // start 用于分页,表示从 start 开始。从 0 开始计数。
- // limit 用于分页,表示拉取 limit 条记录。最大为 30
- res, err := weapp.GetPubTemplateTitleList("access_token", "1,2,3", 0, 10)
- if err != nil {
- // 处理一般错误信息
- return
- }
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### getTemplateList
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getTemplateList.html)
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- // GetTemplateList 获取帐号下已存在的模板列表
- //
- // token 微信 access_token
- res, err := weapp.GetTemplateList("access_token")
- if err != nil {
- // 处理一般错误信息
- return
- }
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### sendSubscribeMessage
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html)
-
- ```go
-
- import "github.com/medivhzhan/weapp/v2"
-
- sender := weapp.SubscribeMessage{
- ToUser: mpOpenID,
- TemplateID: "template-id",
- Page: "mock/page/path",
- MiniprogramState: weapp.MiniprogramStateDeveloper, // 或者: "developer"
- Data: weapp.SubscribeMessageData{
- "first-key": {
- Value: "value",
- },
- "second-key": {
- Value: "value",
- },
- },
- }
-
- res, err := sender.Send("access-token")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
-
- ```
-
- ---
-
- ## 解密
-
- [官方文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html)
-
- > ⚠️ 前端应当先完成[登录](#登录)流程再调用获取加密数据的相关接口。
-
- ### 解密手机号码
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.DecryptMobile("session-key", "encrypted-data", "iv" )
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### 解密分享内容
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.DecryptShareInfo("session-key", "encrypted-data", "iv" )
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### 解密用户信息
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.DecryptUserInfo( "session-key", "raw-data", "encrypted-data", "signature", "iv")
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ### 解密微信运动
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- res, err := weapp.DecryptRunData("session-key", "encrypted-data", "iv" )
- if err != nil {
- // 处理一般错误信息
- return
- }
-
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ---
-
- ## 人脸识别
-
- ```go
- import "github.com/medivhzhan/weapp/v2"
-
- // FaceIdentify 获取人脸识别结果
- //
- // token 微信 access_token
- // key 小程序 verify_result
- res, err := weapp.FaceIdentify("access_token", "verify_result")
- if err != nil {
- // 处理一般错误信息
- return
- }
- if err := res.GetResponseError(); err !=nil {
- // 处理微信返回错误信息
- return
- }
- fmt.Printf("返回结果: %#v", res)
- ```
-
- ---
|