喵提醒开发文档

喵提醒开发文档


按键精灵手机助手代码示例

<p>将以下代码复制到脚本代码的顶部,替换<code>RParamUrl</code>为你的获取参数API网址。<code>MiaoCode</code>保存喵码,喵码通常由用户提供。</p> <pre><code class="language-vb">//获取参数API网址 Dim RParamUrl = &amp;quot;http://miaotixing.com/rparam?rp=rp-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&amp;amp;code=&amp;quot; //喵码,通常由用户输入提供 Dim MiaoCode = &amp;quot;txxxxxx&amp;quot; //API返回的数据 Dim RParamData = Array() //拉取参数数据到变量RParamData。需要注意:参数有缓存,缓存失效后才能拿到用户填写的最新参数。 Function LoadRParam() Dim apiUrl = RParamUrl &amp;amp; MiaoCode &amp;amp; &amp;quot;&amp;amp;type=json&amp;quot; Dim responseText = URL.Get(apiUrl) //TracePrint &amp;quot;RParam API 网址 : &amp;quot; &amp;amp; apiUrl //TracePrint &amp;quot;RParam API 返回:&amp;quot; &amp;amp; responseText RParamData = Encode.JsonToTable(responseText) End Function //读取参数key的值,如果key不存在则返回defValue Function RParam(key, defValue) If IsNull(RParamData[key]) Then RParam = defValue Else RParam = RParamData[key] End If End Function</code></pre> <p>拉取参数时,通过<code>LoadRParam()</code>方式,参数数据会保存到变量RParamData,供后面读取参数时候使用。 读取参数时,通过<code>RParam(key, defValue)</code>方式读取指定key的参数;特殊情况下我们会担心指定key的参数获取失败而影响脚本运行,比如发布新版时候不慎删除某个有用的key,而defValue参数的作用是发现key参数不存在时,以defValue值作为参数值返回。</p> <pre><code class="language-vb">//拉取参数 LoadRParam() //返回key为submited_at的参数值,如果不存在该参数,则返回0 TracePrint &amp;quot;submited_at : &amp;quot; &amp;amp; RParam(&amp;quot;submited_at&amp;quot;, 0) //返回key为key1的参数值,如果不存在该参数,则返回123 TracePrint &amp;quot;key1 : &amp;quot; &amp;amp; RParam(&amp;quot;key1&amp;quot;, 123)</code></pre>

页面列表

ITEM_HTML