|
@@ -17,7 +17,14 @@ class Translate |
|
@@ -17,7 +17,14 @@ class Translate |
|
17
|
{
|
17
|
{
|
|
18
|
//接口地址
|
18
|
//接口地址
|
|
19
|
// public static $url = 'https://translate.hbb618.cn/translates';
|
19
|
// public static $url = 'https://translate.hbb618.cn/translates';
|
|
20
|
- public static $url = 'https://api.cmer.com/translates';
|
20
|
+ public static $url = 'https://api.cmer.com/';
|
|
|
|
21
|
+
|
|
|
|
22
|
+ public static $header = array(
|
|
|
|
23
|
+ 'accept: application/json',
|
|
|
|
24
|
+ 'Content-Type: application/json',
|
|
|
|
25
|
+ 'apikey: UkzZljFv83Z2qBi5YR1o3f2otAVWtug6',
|
|
|
|
26
|
+ 'X-CmerApi-Host:ai_translate.p.cmer.com'
|
|
|
|
27
|
+ );
|
|
21
|
|
28
|
|
|
22
|
public static $tls_list = [
|
29
|
public static $tls_list = [
|
|
23
|
'en' => [
|
30
|
'en' => [
|
|
@@ -734,7 +741,7 @@ class Translate |
|
@@ -734,7 +741,7 @@ class Translate |
|
734
|
'sl' => 'auto',
|
741
|
'sl' => 'auto',
|
|
735
|
'tls' => $tls,
|
742
|
'tls' => $tls,
|
|
736
|
];
|
743
|
];
|
|
737
|
- return Http::post(self::$url.$action, $data);
|
744
|
+ return http_post(self::$url.$action, json_encode($data),self::$header);
|
|
738
|
}
|
745
|
}
|
|
739
|
|
746
|
|
|
740
|
/**
|
747
|
/**
|
|
@@ -749,11 +756,8 @@ class Translate |
|
@@ -749,11 +756,8 @@ class Translate |
|
749
|
if (!$texts) {
|
756
|
if (!$texts) {
|
|
750
|
return '';
|
757
|
return '';
|
|
751
|
}
|
758
|
}
|
|
752
|
-
|
|
|
|
753
|
- $retsult = self::translate($texts, $tls)->json();
|
|
|
|
754
|
-
|
|
|
|
755
|
- return $retsult[0]['texts'] ?? '';
|
|
|
|
756
|
-
|
759
|
+ $result = self::translate($texts, $tls);
|
|
|
|
760
|
+ return $result[0]['texts'] ?? '';
|
|
757
|
}
|
761
|
}
|
|
758
|
/**
|
762
|
/**
|
|
759
|
* 翻译带源语种
|
763
|
* 翻译带源语种
|
|
@@ -772,7 +776,7 @@ class Translate |
|
@@ -772,7 +776,7 @@ class Translate |
|
772
|
'sl' => 'auto',
|
776
|
'sl' => 'auto',
|
|
773
|
'tl' => $tl,
|
777
|
'tl' => $tl,
|
|
774
|
];
|
778
|
];
|
|
775
|
- return Http::post(self::$url . $action, $data);
|
779
|
+ return http_post(self::$url.$action, json_encode($data),self::$header);
|
|
776
|
}
|
780
|
}
|
|
777
|
|
781
|
|
|
778
|
} |
782
|
} |