# getWXACodeUnlimit
### getWXACodeUnlimit
获取小程序码,适用于需要的码数量极多的业务场景。**通过该接口生成的小程序码,永久有效,数量暂无限制。** 更多用法详见 [获取二维码](https://developers.weixin.qq.com/minigame/dev/tutorial/open-ability/qr-code.html)。
#### 请求地址
```
<pre class="prettyprint"><ol class="linenums"><li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln">POST https</span><span class="pun">:</span><span class="com">//api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN</span></code></li></ol>
```
#### 参数
##### string access\_token
[接口调用凭证](/read/wechat-game-api/297.md)
##### string scene
最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:`!#$&'()*+,/:;=?@-._~`,其它字符请自行编码为合法字符(因不支持`%`,中文无法使用 `urlencode` 处理,请使用其他编码方式)
##### string page
必须是已经发布的小程序存在的页面(否则报错),例如 `pages/index/index`, 根路径前不要填加 `/`,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
##### number width
二维码的宽度,默认为 430px,最小 280px,最大 1280px
##### boolean auto\_color
自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
##### Object line\_color
auto\_color 为 false 时生效,使用 rgb 设置颜色 例如 `{"r":"xxx","g":"xxx","b":"xxx"}` 十进制表示,默认全 0
##### boolean is\_hyaline
是否需要透明底色,为 true 时,生成透明底色的小程序码,默认 false
#### 返回值
##### Object
返回的 JSON 数据包
属性类型说明支持版本errcodenumber错误码errmsgstring错误信息**errcode 的合法值**
值说明45009调用分钟频率受限(目前5000次/分钟,会调整),如需大量小程序码,建议预生成。41030所传page页面不存在,或者小程序没有发布#### 返回值说明
如果调用成功,会直接返回图片二进制内容,如果请求失败,会返回 JSON 格式的数据。
#### 注意
- POST 参数需要转成 JSON 字符串,不支持 form 表单提交。
- 接口只能生成已发布的小程序的二维码
- 调用分钟频率受限(5000次/分钟),如需大量小程序码,建议预生成#### 获取 scene 值
scene 字段的值会作为 query 参数传递给小程序/小游戏。用户扫描该码进入小程序/小游戏后,开发者可以获取到二维码中的 scene 值,再做处理逻辑。
调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 `encodeURIComponent`
**小程序**
```
<pre class="prettyprint"><ol class="linenums"><li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="typ">Page</span><span class="pun">({</span></code></li>
<li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> onLoad </span><span class="pun">(</span><span class="pln">query</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li>
<li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="com">// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene</span></code></li>
<li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> scene </span><span class="pun">=</span><span class="pln"> decodeURIComponent</span><span class="pun">(</span><span class="pln">query</span><span class="pun">.</span><span class="pln">scene</span><span class="pun">)</span></code></li>
<li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="pun">}</span></code></li>
<li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pun">})</span></code></li>
</ol>
```
**小游戏**
```
<pre class="prettyprint"><ol class="linenums"><li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln">wx</span><span class="pun">.</span><span class="pln">onShow</span><span class="pun">(</span><span class="hljs-params"><span class="kwd">function</span></span><span class="pln"> </span><span class="pun">(</span><span class="hljs-params"><span class="pun">{</span><span class="pln">query</span><span class="pun">}</span></span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li>
<li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="com">// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene</span></code></li>
<li class="l"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pln"> </span><span class="kwd">const</span><span class="pln"> scene </span><span class="pun">=</span><span class="pln"> decodeURIComponent</span><span class="pun">(</span><span class="pln">query</span><span class="pun">.</span><span class="pln">scene</span><span class="pun">)</span></code></li>
<li class="l1"><code class="pcalibre9 pcalibre8 pcalibre7"><span class="pun">})</span></code></li>
</ol>
```
> 原文: <https://developers.weixin.qq.com/minigame/dev/api/open-api/qr-code/getWXACodeUnlimit.html>
- 致谢
- 渲染
- 画布
- wx.createCanvas
- Canvas
- .toTempFilePath
- .toTempFilePathSync
- .getContext
- .toDataURL
- RenderingContext
- 图片
- wx.createImage
- Image
- 字体
- wx.getTextLineHeight
- wx.loadFont
- 帧率
- wx.setPreferredFramesPerSecond
- cancelAnimationFrame
- requestAnimationFrame
- 分包加载
- wx.loadSubpackage
- LoadSubpackageTask
- .onProgressUpdate
- 设备
- 设备方向
- wx.startDeviceMotionListening
- wx.stopDeviceMotionListening
- wx.onDeviceMotionChange
- 加速计
- wx.startAccelerometer
- wx.stopAccelerometer
- wx.onAccelerometerChange
- 剪贴板
- wx.getClipboardData
- wx.setClipboardData
- 罗盘
- wx.startCompass
- wx.stopCompass
- wx.onCompassChange
- 陀螺仪
- wx.startGyroscope
- wx.stopGyroscope
- wx.onGyroscopeChange
- 电量
- wx.getBatteryInfo
- wx.getBatteryInfoSync
- 网络
- wx.getNetworkType
- wx.onNetworkStatusChange
- 振动
- wx.vibrateShort
- wx.vibrateLong
- 性能
- wx.onMemoryWarning
- 屏幕
- wx.getScreenBrightness
- wx.setKeepScreenOn
- wx.setScreenBrightness
- 转屏
- wx.onDeviceOrientationChange
- wx.offDeviceOrientationChange
- 系统
- 系统信息
- wx.getSystemInfo
- wx.getSystemInfoSync
- 系统事件
- wx.onAudioInterruptionBegin
- wx.offAudioInterruptionBegin
- wx.onAudioInterruptionEnd
- wx.offAudioInterruptionEnd
- wx.onError
- wx.offError
- 生命周期
- wx.exitMiniProgram
- wx.getLaunchOptionsSync
- wx.onHide
- wx.offHide
- wx.onShow
- wx.offShow
- 触摸事件
- wx.onTouchStart
- wx.offTouchStart
- wx.onTouchMove
- wx.offTouchMove
- wx.onTouchEnd
- wx.offTouchEnd
- wx.onTouchCancel
- wx.offTouchCancel
- Touch
- 位置
- wx.getLocation
- 媒体
- 图片
- wx.chooseImage
- wx.previewImage
- wx.saveImageToPhotosAlbum
- 音频
- wx.createInnerAudioContext
- wx.getAvailableAudioSources
- wx.setInnerAudioOption
- InnerAudioContext
- .pause
- .stop
- .seek
- .destroy
- .offCanplay
- .onPlay
- .offPlay
- .onPause
- .offPause
- .onStop
- .offStop
- .onEnded
- .offEnded
- .onTimeUpdate
- .offTimeUpdate
- .onError
- .onCanplay
- .offError
- .onWaiting
- .offWaiting
- .onSeeking
- .offSeeking
- .onSeeked
- .offSeeked
- .play
- 录音
- wx.getRecorderManager
- RecorderManager
- .start
- .pause
- .resume
- .stop
- .onStart
- .onResume
- .onPause
- .onStop
- .onFrameRecorded
- .onError
- .onInterruptionBegin
- .onInterruptionEnd
- 视频
- wx.createVideo
- Video
- .onWaiting
- .offWaiting
- .onPlay
- .offPlay
- .onPause
- .offPause
- .onEnded
- .offEnded
- .onTimeUpdate
- .offTimeUpdate
- .onError
- .offError
- .destroy
- .play
- .pause
- .stop
- .seek
- .requestFullScreen
- .exitFullScreen
- 文件
- wx.getFileSystemManager
- FileSystemManager
- .access
- .accessSync
- .appendFile
- .appendFileSync
- .saveFile
- .saveFileSync
- .getSavedFileList
- .removeSavedFile
- .copyFile
- .copyFileSync
- .getFileInfo
- .mkdir
- .mkdirSync
- .readFile
- .readFileSync
- .readdir
- .readdirSync
- .rename
- .renameSync
- .rmdir
- .rmdirSync
- .stat
- .statSync
- .unlink
- .unlinkSync
- .unzip
- .writeFile
- .writeFileSync
- Stats
- .isDirectory
- .isFile
- 网络
- 下载
- wx.downloadFile
- DownloadTask
- .onProgressUpdate
- .abort
- 发起请求
- wx.request
- RequestTask
- .abort
- WebSocket
- wx.connectSocket
- wx.closeSocket
- wx.sendSocketMessage
- wx.onSocketOpen
- wx.onSocketClose
- wx.onSocketMessage
- wx.onSocketError
- SocketTask
- .close
- .onOpen
- .onClose
- .onError
- .onMessage
- .send
- 上传
- wx.uploadFile
- UploadTask
- .onProgressUpdate
- .abort
- 开放接口
- 游戏圈
- wx.createGameClubButton
- GameClubButton
- .onTap
- .offTap
- .show
- .hide
- .destroy
- 开放数据
- wx.getFriendCloudStorage
- wx.getGroupCloudStorage
- wx.getUserCloudStorage
- wx.removeUserCloudStorage
- wx.setUserCloudStorage
- wx.getSharedCanvas
- UserGameData
- KVData
- removeUserStorage
- setUserStorage
- 授权
- wx.authorize
- 防沉迷
- wx.checkIsUserAdvisedToRest
- 用户信息
- wx.getUserInfo
- wx.createUserInfoButton
- UserInfo
- UserInfoButton
- .show
- .hide
- .destroy
- .onTap
- .offTap
- 微信运动
- wx.getWeRunData
- 设置
- wx.getSetting
- wx.openSetting
- wx.createOpenSettingButton
- OpenSettingButton
- .onTap
- .offTap
- .show
- .hide
- .destroy
- AuthSetting
- 登录
- wx.login
- wx.checkSession
- checkSessionKey
- code2Session
- 意见反馈
- wx.createFeedbackButton
- FeedbackButton
- .onTap
- .offTap
- .show
- .hide
- .destroy
- 小程序跳转
- wx.navigateToMiniProgram
- 客服消息
- wx.openCustomerServiceConversation
- 开放数据域
- wx.getOpenDataContext
- wx.onMessage
- OpenDataContext
- .postMessage
- 接口调用凭证
- getAccessToken
- 内容安全
- imgSecCheck
- msgSecCheck
- 二维码
- createWXAQRCode
- getWXACode
- getWXACodeUnlimit
- 调试
- wx.setEnableDebug
- console
- .groupEnd
- .debug
- .log
- .info
- .warn
- .error
- .group
- 数据缓存
- wx.getStorage
- wx.getStorageSync
- wx.setStorage
- wx.setStorageSync
- wx.removeStorage
- wx.removeStorageSync
- wx.clearStorage
- wx.clearStorageSync
- wx.getStorageInfo
- wx.getStorageInfoSync
- 更新
- wx.getUpdateManager
- UpdateManager
- .onCheckForUpdate
- .onUpdateReady
- .onUpdateFailed
- .applyUpdate
- Worker
- wx.createWorker
- Worker
- .postMessage
- .onMessage
- .terminate
- 转发
- wx.getShareInfo
- wx.hideShareMenu
- wx.showShareMenu
- wx.updateShareMenu
- wx.shareAppMessage
- wx.onShareAppMessage
- wx.offShareAppMessage
- 广告
- wx.createRewardedVideoAd
- wx.createBannerAd
- RewardedVideoAd
- .load
- .show
- .onLoad
- .offLoad
- .onError
- .offError
- .onClose
- .offClose
- BannerAd
- .show
- .hide
- .destroy
- .onResize
- .offResize
- .onLoad
- .offLoad
- .onError
- .offError
- 界面
- 交互
- wx.showToast
- wx.showModal
- wx.hideToast
- wx.showLoading
- wx.hideLoading
- wx.showActionSheet
- 菜单
- wx.getMenuButtonBoundingClientRect
- wx.setMenuStyle
- 键盘
- wx.showKeyboard
- wx.hideKeyboard
- wx.updateKeyboard
- wx.onKeyboardInput
- wx.offKeyboardInput
- wx.onKeyboardConfirm
- wx.offKeyboardConfirm
- wx.onKeyboardComplete
- wx.offKeyboardComplete
- 状态栏
- wx.setStatusBarStyle
- 窗口
- wx.onWindowResize
- wx.offWindowResize
- 性能
- wx.getPerformance
- wx.triggerGC
- Performance
- .now
- 虚拟支付
- wx.requestMidasPayment
- midasCancelPay
- midasGetBalance
- midasPay
- midasPresent
- 定时器
- setTimeout
- clearTimeout
- setInterval
- clearInterval