Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘小敏
loveisland
Commits
ea8bb346
Commit
ea8bb346
authored
May 12, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AI试戴 接口增加日志
parent
f40b76ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
Ai.php
addons/shopro/service/user/Ai.php
+13
-5
No files found.
addons/shopro/service/user/Ai.php
View file @
ea8bb346
...
...
@@ -11,7 +11,7 @@ class Ai
{
// 火山引擎方舟配置
private
$ark_host
=
'https://ark.cn-beijing.volces.com'
;
private
$api_key
=
''
;
//
我的个人K
ey
private
$api_key
=
''
;
//
AI接口k
ey
public
function
__construct
(){
$this
->
api_key
=
config
(
'shopro.ai_api_key'
);
...
...
@@ -48,6 +48,9 @@ class Ai
'verify'
=>
false
,
// 关闭 SSL 证书验证
'allow_redirects'
=>
true
];
// 记录入参日志
Log
::
info
(
'用户ID:'
.
$userId
.
' response_format'
.
$response_format
.
' AI生成图片接口入参:'
.
json_encode
(
$params
));
// 发送请求
$client
=
new
Http
();
$response
=
$client
->
post
(
$url
,
$params
);
...
...
@@ -57,8 +60,8 @@ class Ai
$content
=
preg_replace
(
'/[^\x20-\x7E]/'
,
''
,
$content
);
$result
=
json_decode
(
$content
,
true
);
// 记录日志
Log
::
info
(
'用户ID:'
.
$userId
.
' AI生成图片接口返回:'
.
json_encode
(
$result
));
// 记录
出参
日志
Log
::
info
(
'用户ID:'
.
$userId
.
' response_format'
.
$response_format
.
' AI生成图片接口返回:'
.
json_encode
(
$result
));
if
(
$response_format
==
'b64_json'
){
if
(
!
$result
||
!
isset
(
$result
[
'data'
][
0
][
'b64_json'
]))
{
...
...
@@ -93,7 +96,7 @@ class Ai
];
}
catch
(
\Exception
$e
)
{
Log
::
error
(
'用户ID:'
.
$userId
.
' AI生成图片异常:'
.
$e
->
getMessage
());
Log
::
error
(
'用户ID:'
.
$userId
.
' response_format'
.
$response_format
.
' AI生成图片异常:'
.
$e
->
getMessage
());
return
[
'code'
=>
0
,
'msg'
=>
'请求异常:'
.
$e
->
getMessage
()
...
...
@@ -146,6 +149,10 @@ class Ai
'verify'
=>
false
,
// 关闭 SSL 证书验证
'allow_redirects'
=>
true
];
// 记录入参日志
Log
::
info
(
'用户ID:'
.
$userId
.
' AI生成视频接口入参:'
.
json_encode
(
$params
));
// 发送请求
$client
=
new
Http
();
$response
=
$client
->
post
(
$url
,
$params
);
...
...
@@ -155,8 +162,9 @@ class Ai
$content
=
preg_replace
(
'/[^\x20-\x7E]/'
,
''
,
$content
);
$result
=
json_decode
(
$content
,
true
);
// 记录日志
// 记录
出参
日志
Log
::
info
(
'用户ID:'
.
$userId
.
' AI生成视频接口返回:'
.
json_encode
(
$result
));
return
[
'code'
=>
1
,
'msg'
=>
'视频生成中'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment