getData(true); if (!is_array($payload)) { return $response; } // 与 jok 约定一致:成功 code 为 0;字符串 "0" 一并兼容 if (($payload['code'] ?? null) != 0 || !array_key_exists('result', $payload)) { return $response; } $payload['result'] = $this->checkHttp($payload['result']); $response->setData($payload); return $response; } /** * 递归把字符串/数组/对象中的 http:// 换成 https:// * 不用 PHPUnit 的 isObject,对象先转数组再走 */ private function checkHttp(mixed $data): mixed { if (is_object($data)) { $data = json_decode(json_encode($data), true); } if (is_string($data)) { return str_replace('http://', 'https://', $data); } if (is_array($data)) { array_walk_recursive($data, function (&$value) { if (is_string($value)) { $value = str_replace('http://', 'https://', $value); } }); return $data; } return $data; } }