From dd5543b3677e0cef821fcc8a92284b56ff669089 Mon Sep 17 00:00:00 2001 From: banditsmile Date: Fri, 15 Mar 2019 11:24:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=97=AE=E9=A2=98=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/Deal.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/application/controllers/Deal.php b/application/controllers/Deal.php index abcfc57..be9f4e7 100644 --- a/application/controllers/Deal.php +++ b/application/controllers/Deal.php @@ -44,10 +44,14 @@ } //上面验证通过,继续执行 //取出tinypng key - $kyes = $row['values']; - $kyes = json_decode($kyes); - $i = 'api'.rand(1,2); - $key = $kyes->$i; + //拼写错误处理 + $keys = $row['values']; + + //可以使用任意多个key + //@todo 建议使用列表类型而不是联名数组类型保存key + $keys = json_decode($keys, true); + $i = 'api'.rand(1, count($keys)); + $key = $keys[$i-1]; $url = "https://api.tinify.com/shrink"; $data = file_get_contents($path);