函数库,必看
<pre><code class="language-lua">//注意,所有的代码都依赖于函数库,首先把函数库复制到代码里,修改下面两个信息
//注意,所有的代码都依赖于函数库,首先把函数库复制到代码里,修改下面两个信息
Function Request(api, 参数)
//-------------------------------------------这里是需要修改的参数
API密码 = &quot;xxx&quot;//在后台的设置,或者APP的通用设置里面找
开发者ID = &quot;xxx&quot;//在后台左上角,或者APP【我的】中的【VID】
//--------------------------------------------------------------
Randomize
ApiList = array(&quot;https://napi.2cccc.cc/&quot;, &quot;http://api2.2cccc.cc/&quot;, &quot;http://api3.2cccc.cc/&quot;)
Host = ApiList(Int((UBound(ApiList) - 0 + 1) * Rnd() + 0))
时间戳 = timestamp(0)
connect_times = 0
签名 = Plugin.Encrypt.Md5String(API密码 &amp; 时间戳)
common_params = &quot;center_id=&quot; &amp; 开发者ID &amp; &quot;&amp;tmstamp=&quot; &amp; 时间戳 &amp; &quot;&amp;sign=&quot; &amp; 签名
Res = Lib.网络.获得网页源文件_增强版(Host &amp; api &amp; &quot;?&quot; &amp; common_params &amp; &quot;&amp;&quot; &amp; 参数, &quot;utf-8&quot;)
connect_times = 0
Do While Instr(1, Res, &quot;code&quot;, 1) = 0
Rand = Int((UBound(ApiList) - 0 + 1) * Rnd() + 0)
Host = ApiList(Int((UBound(ApiList) - 0 + 1) * Rnd() + 0))
Res = Lib.网络.获得网页源文件_增强版(Host &amp; api &amp; &quot;?&quot; &amp; common_params &amp; &quot;&amp;&quot; &amp; 参数, &quot;utf-8&quot;)
connect_times = connect_times + 1
If Instr(1, Res, &quot;code&quot;, 1) = 0 and connect_times &gt; 1 Then
TracePrint &quot;连接服务器失败,正在尝试重新请求&quot;
Delay 2000
End If
If connect_times &gt; 30 Then
Request = array(0, &quot;无法连接服务器&quot;)
Exit Do
End If
Loop
If json_decode(Res, &quot;code&quot;) = 1 Then
If UCase(Plugin.Encrypt.Md5String(json_decode(Res, &quot;timestamp&quot;) &amp; API密码)) = Ucase(json_decode(Res, &quot;sign&quot;)) and Abs(clng(时间戳) - clng(json_decode(Res,&quot;timestamp&quot;))) &lt; 600 Then
Request = array(1, Res)
Else
Request = array(0,&quot;请检查API密码是否填写正确&quot;)
End If
Else
msg = json_decode(Res, &quot;msg&quot;)
If msg = &quot;&quot; Then
msg = &quot;连接服务器失败&quot;
End If
Request = array(0,msg)
End If
End Function
Function json_decode(str,json路径)
Set sc = CreateObject(&quot;MSScriptControl.ScriptControl&quot;)
sc.Language = &quot;JScript&quot;
sc.AddCode &quot;var tmp = &quot; &amp; str &amp; &quot;;&quot;
json_decode = sc.Eval(&quot;tmp.&quot; &amp; json路径)
End Function
Function timestamp(times)
If times = 0 Then
淘宝时间戳JSON = Lib.网络.获得网页源文件_增强版(&quot;http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp&quot;, &quot;utf-8&quot;)
淘宝时间戳 = json_decode(淘宝时间戳JSON, &quot;data.t&quot;)
If 淘宝时间戳 &lt;&gt; &quot;&quot; Then
TracePrint &quot;获取淘宝时间戳成功&quot;
timestamp = left(淘宝时间戳, 10)
Else
TracePrint &quot;获取淘宝时间戳失败,开始获取拼多多时间戳&quot;
timestamp = timestamp(times + 1)
End If
End If
If times = 1 Then
拼多多时间戳JSON = Lib.网络.获得网页源文件_增强版(&quot;http://api.pinduoduo.com/api/server/_stm&quot;, &quot;utf-8&quot;)
拼多多时间戳 = json_decode(拼多多时间戳JSON, &quot;server_time&quot;)
If 拼多多时间戳 &lt;&gt; &quot;&quot; Then
TracePrint &quot;获取拼多多时间戳成功&quot;
timestamp = left(拼多多时间戳, 10)
Else
TracePrint &quot;获取拼多多时间戳失败,开始获取世界时间戳&quot;
timestamp = timestamp(times + 1)
End If
End If
If times = 2 Then
世界时间戳JSON = Lib.网络.获得网页源文件_增强版(&quot;http://worldtimeapi.org/api/timezone/Asia/Shanghai&quot;, &quot;utf-8&quot;)
世界时间戳 = json_decode(世界时间戳JSON, &quot;unixtime&quot;)
If 世界时间戳 &lt;&gt; &quot;&quot; Then
TracePrint &quot;获取世界时间戳成功&quot;
timestamp = left(世界时间戳, 10)
Else
TracePrint &quot;获取世界时间戳失败,开始获取本地时间戳&quot;
timestamp = timestamp(times + 1)
End If
End If
If times = 3 Then
TracePrint &quot;获取本地时间戳&quot;
timestamp = DateDiff(&quot;s&quot;, &quot;1970-01-01 00:00:00&quot;, Now)
End If
End Function</code></pre>