client->call('print/index', array ( 'machine_code' => $machineCode, 'content' => $content, 'origin_id' => $originId )); if (is_null($res)) { throw new Exception("invalid response."); } if ($res->error == 18 && $printer) { $printer_model = new Printer(); $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]); $access_token = $printer_model->getYlyToken($config, $printer[ 'site_id' ], 1); $this->index($machineCode, $content, $originId, []); } if (isset($res->error) && $res->error != 0) { $errorDescription = isset($res->body) ? $res->error_description . $res->body : $res->error_description; throw new Exception('Call method print/index error code is ' . $res->error . ' error message is ' . $errorDescription); } } }