/**
  * 
  *
  * @return array|bool 
  * @throws DictionaryException
  * @throws ForbiddenException
  * @static 
  */
 public static function getLanguages()
 {
     return \Yandex\Dictionary\DictionaryClient::getLanguages();
 }
예제 #2
0
            $from = $translation[0];
            $to = $translation[1];
            $dictionaryClient->setTranslateFrom($from)->setTranslateTo($to);
            $result = $dictionaryClient->lookup($_POST['word']);
            if ($result) {
                /** @var \Yandex\Dictionary\DictionaryDefinition $dictionaryDefinition */
                $dictionaryDefinition = $result[0];
                $dictionaryTranslation = $dictionaryDefinition->getTranslations();
                /** @var \Yandex\Dictionary\DictionaryTranslation $dictionaryTranslation */
                $dictionaryTranslation = $dictionaryDefinition->getTranslations()[0];
                $word = $dictionaryTranslation->getText();
            }
        }
    }
    try {
        $languages = $dictionaryClient->getLanguages();
    } catch (ForbiddenException $ex) {
        $errorMessage = $ex->getMessage();
        $errorMessage .= '<p>Возможно, у приложения нет прав на доступ к ресурсу. Попробуйте ' . '<a href="' . rtrim(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__), "/") . "/../OAuth/" . '">авторизироваться</a> и повторить.</p>';
    } catch (Exception $ex) {
        $errorMessage = $ex->getMessage();
    }
}
?>
<!doctype html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>Yandex PHP Library: DataSync Demo</title>
    <link rel="stylesheet" href="//yandex.st/bootstrap/3.0.0/css/bootstrap.min.css">
    <link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">