我尝试使用这个github库
https://github.com/detectlanguage/detectlanguage-php
我之前注册了API密钥。
我的代码非常简单,但是立即引发了未捕获的期望:
require_once 'includes/detectlanguage/lib/detectlanguage.php';
use \DetectLanguage\DetectLanguage;
DetectLanguage::setApiKey("xxxxxxx7687af9cb91950327ea");
$languageCode = DetectLanguage::simpleDetect("Hallo und einen schönen Tag");
Fatal error: Uncaught exception 'DetectLanguage\Error' with message 'Invalid server response: ' in /var/www/bodo/dokumente-online.com/includes/detectlanguage/lib/DetectLanguage/Client.php:45 Stack trace: #0 /var/www/bodo/dokumente-online.com/includes/detectlanguage/lib/DetectLanguage/DetectLanguage.php(80): DetectLanguage\Client::request('detect', Array) #1 /var/www/bodo/dokumente-online.com/test_detect.php(7): DetectLanguage\DetectLanguage::detect('HAllo und einen...') #2 {main} thrown in /var/www/xyz.com/includes/detectlanguage/lib/DetectLanguage/Client.php on line 45
知道我在做什么错吗? 服务似乎可以正常工作。