MidJourneyService.php
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* @remark :
* @name :MidJourneyService.php
* @author :lyh
* @method :post
* @time :2025/8/2 10:48
*/
namespace App\Services;
use Illuminate\Support\Facades\Http;
class MidJourneyService
{
/**
* 请求域名
* @var string
*/
public $url = 'https://api.cmer.com';
public $header = [
'apikey' => 'UkzZljFv83Z2qBi5YR1o3f2otAVWtug6',
'X-CmerApi-Host' => 'aiccmj.p.cmer.com',
];
/**
* @remark :提交生成图片
* @name :imagine
* @author :lyh
* @method :post
* @time :2025/8/2 10:50
*/
public function imagine($content, string $refer_img = ''){
try {
$data = ['prompt' => $content];
//回调地址
$data['callback_url'] = route('api.ImageCallBack');
$result = Http::withHeaders($this->header)->withoutVerifying()->post($this->url.'/v1/api/trigger/imagine', $data);
$json = $result->json();
}catch (\Throwable $e){
dump($e->getMessage());
$json = [];
}
return $json ?: [];
}
/**
* 扩展图片
* @param $index
* @param $msg_id
* @param $msg_hash
* @param $trigger_id
* @return array|mixed
*/
public function upscale($index, $msg_id, $msg_hash, $trigger_id){
try {
$result = Http::withHeaders($this->header)->withoutVerifying()->post($this->url.'/v1/api/trigger/upscale', [
"index" => $index,
"msg_id" => $msg_id,
"msg_hash" => $msg_hash,
"trigger_id" => $trigger_id
]);
$json = $result->json();
}catch (\Throwable $e){
$json = [];
}
return $json;
}
/**
* 优化图片
* @param $index
* @param $msg_id
* @param $msg_hash
* @param $trigger_id
* @return array|mixed
*/
public function variation($index, $msg_id, $msg_hash, $trigger_id){
try {
$result = Http::withHeaders($this->header)->withoutVerifying()->post($this->url.'/v1/api/trigger/variation', [
"index" => $index,
"msg_id" => $msg_id,
"msg_hash" => $msg_hash,
"trigger_id" => $trigger_id
]);
$json = $result->json();
}catch (\Throwable $e){
$json = [];
}
return $json;
}
}