Obtenir votre clé API sur Dixit.com
Note: Pour pouvoir utiliser l'API Dixit, vous devez impérativement disposer des informations de connection à votre compte Dixit (email et mot de passe) ainsi que de votre clé API.
Vous pouvez directement obtenir cette clé API depuis votre espace client, dans l'onglet "informations personnelles".Démarrer l'intégration
En préambule à toute communication à Dixit, il est nécessaire d'obtenir un "token de connection".
Ce token reste utilisable au cours d'une session.
C'est la fonction openApiConnection qui retourne un token unique pour chaque session.
$login = "myLogin"; // your Dixit login $pwd = "myPwd"; // your Dixit password $key = "myApiKey"; // your API key $sClient = new SoapClient("http://api.dixit.com/dixit_api.wsdl", array ( 'wsdl_cache' => WSDL_CACHE_NONE, 'trace' => 1 )); $response = $sClient->openApiConnection(array ('login'=>$login, 'pwd'=>$pwd, 'key'=>$key)); $token = $response->return;
Ce token de connection est utilisé par toutes les autres fonctions.
Si vous parvenez à obtenir ce token, c'est que vous êtes en mesure de communiquer via l'API.
Liste des fonctions
- openApiConnection()
- getTranslationInfo()
- getTextInfo()
- createText()
- createTranslation()
- getBalance()
- getTextDetail()
- createTextMulti()
- getTranslationMultiInfo()
- getCategories()
- getLanguages()
- getWordCount()
Ouvre votre connection à l'API Dixit.
Paramètres d'entrée :array ( 'login' => $login, 'pwd' => $pwd, 'key' => $key );
Paramètres de sortie :
Object { var return; // the connection token to use in all other API calls }
Exemple d'utilisation :
$login = "myLogin"; // your Dixit login $pwd = "myPwd"; // your Dixit password $key = "myApiKey"; // your API key $sClient = new SoapClient("http://api.dixit.com/dixit_api.wsdl", array ( 'wsdl_cache' => WSDL_CACHE_NONE, 'trace' => 1 )); $response = $sClient->openApiConnection(array ('login'=>$login, 'pwd'=>$pwd, 'key'=>$key)); $token = $response->return;
Retourne les informations sur une traduction lorsqu'elle est terminée
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'id' => $translation_id, // your translation's id 'html' => $html // optional : if true, the fonction return the translation including html tags );
Paramètres de sortie :
Object { var ready; // boolean : true if the translation is finish, false otherwise object getTranslationInfoReturn { var idTranslation; // your translation's id var idLanguage; // your translation's language id var outputText; // the translation text } }
Exemple d'utilisation :
class translation { var $idTranslation; var $idLanguage; var $outputText; function __construct() { $this->idTranslation = 0; $this->idLanguage = 0; $this->outputText = ""; } } /* Note : Suppose that $token and $sClient are created */ $translationId = 123; // The ID of your translation $result = $sClient->getTranslationInfo (array ('token'=> $token, 'id' => $translationId)); if ($result->ready) { $myTranslation = new translation(); $myTranslation = $result->getTranslationInfoReturn; }
Retourne des informations sur un texte.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'id' => $translation_id, // your text's id );
Paramètres de sortie :
Object { object getTextInfoReturn { var source_text; // the source text var source_language_id; // the language of yout text var category_id; // the category var comment; // your comment about this text var name; // the name of your text var url_photo; // An image URL to show to the translator } }
Exemple d'utilisation :
class text { var $source_text; var $source_language_id; var $category_id; var $comment; var $name; var $url_photo; function __construct() { $this->source_text = ""; $this->source_language_id = 0; $this->category_id = 0; $this->comment = ""; $this->name = ""; $this->url_photo = ""; } } /* Note : Suppose that $token and $sClient are created */ $textId = 123; // The ID of your text $result = $sClient->getTextInfo (array ('token'=> $token, 'id' => $textId)); if ($result->ready) { $my_text = new text(); $my_text = $result->getTextInfoReturn; }
Crée un nouveau texte source sur Dixit.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'text' => object { var $source_text; // the source text var $source_language_id; // the language of yout text var $category_id; // the category var $comment; // your comment about this text var $name; // the name of your text var $url_photo; // An image URL to show to the translator } );
Paramètres de sortie :
Object { var createTextReturn; // The unique ID of ths new created text }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created, and class text is included */ $text = new text(); $text->source_text = "my source text"; $text->source_language_id = 38; // corresponding to english language $text->category_id = 55; // category "fashion, clothing, jewelry" $text->comment = "a comment"; $text->name = "a title"; $text->url_photo = "http://www.domain.com/images/an_image.gif"; $my_text_id = $sClient->createText (array ('token'=> $token, 'text' => $text));
Crée une nouvelle traduction sur Dixit à partir d'un texte source, et de la langue cible.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'text_id' => $text_id, // Tee unique ID of the source text 'output_language_id' => $output_language_id, // the id of the target language 'proofreading' => $proofreading, // Optional boolean (1 = adds proofreading for this translation. 0 = nothing) );
Paramètres de sortie :
Object { var createTranslationReturn; // The unique ID of ths new created translation }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created. */ $text = new text(); $text->source_text = "my source text"; $text->source_language_id = 38; // corresponding to english language $text->category_id = 55; // category "fashion, clothing, jewelry" $text->comment = "a comment"; $text->name = "a title"; $text->url_photo = "http://www.domain.com/images/an_image.gif"; $my_text_id = $sClient->createText (array ('token'=> $token, 'text' => $text)); $output_language_id = 48 // corresponding to "french" $my_translation_id = $sClient->createTranslation (array ('token'=> $token, 'text_id' => $my_text_id, 'output_language_id' => $output_language_id)); /* Result the création of the translation (id = $my_translation_id) from the source text (id = $my_text_id) to the target language (id = $output_language_id) */
Retourne vos informations de solde client sur Dixit.
Paramètres d'entrée :array ( 'token' => $token, // your connection token );
Paramètres de sortie :
Object { var total_credits; // Your current balance var available_credits; // Your available credits var captured_credits; // Your frozen credits }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created. */ $my_balance = $sClient->getBalance (array ('token'=> $token)); echo $my_balance->available_credits;
Retourne le détail de toutes les traductions correspondants à un texte source.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'id' => $my_text_id, // your text's unique ID );
Paramètres de sortie :
Object { object textDetail { var $source_text; var $source_language_id; var $category_id; var $comment; var $name; var $url_photo; } object available_translations Collection { var $idTranslation; var $idLanguage; var $outputText; // will allways be empty } object pending_translations Collection { var $idTranslation; var $idLanguage; var $outputText; // will allways be empty } object completed_translations Collection { var $idTranslation; var $idLanguage; var $outputText; } }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created. $my_text_id is one of your text */ $my_text_detail = $sClient->getTextDetail (array ('token'=> $token, 'id' => $my_text_id)); print_r $my_text_detail; /* will print : object(stdClass)#3 (1) { ["getTextDetailResult"]=> object(stdClass)#4 (4) { ["textDetail"]=> object(stdClass)#5 (6) { ["source_text"]=> string(44) "My source text" ["source_language_id"]=> string(2) "38" ["category_id"]=> string(2) "55" ["comment"]=> string(9) "a comment" ["name"]=> string(7) "a title" ["url_photo"]=> string(41) "http://www.domain.com/images/an_image.gif" } ["available_translations"]=> object(stdClass)#6 (2) { ["translation_1"]=> object(stdClass)#7 (4) { ["idTranslation"]=> string(3) "530" ["idLanguage"]=> string(2) "55" ["outputText"]=> string(0) "" } ["translation_2"]=> object(stdClass)#8 (4) { ["idTranslation"]=> string(3) "538" ["idLanguage"]=> string(3) "175" ["outputText"]=> string(0) "" } } ["pending_translations"]=> object(stdClass)#9 (1) { ["translation_1"]=> object(stdClass)#10 (4) { ["idTranslation"]=> string(3) "532" ["idLanguage"]=> string(3) "132" ["outputText"]=> string(0) "" } } ["completed_translations"]=> object(stdClass)#11 (1) { ["translation_1"]=> object(stdClass)#12 (4) { ["idTranslation"]=> string(3) "531" ["idLanguage"]=> string(2) "48" ["outputText"]=> string(18) "Votre traduction en français" } } } } */
Crée un nouveau texte source sur Dixit, en utilisant le système de "blocs de textes". L'ensemble de blocs est fait sous la forme d'un "tableau de tableaux", encodé avec Json, et dont les entrées sont définies ci-dessous.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'text' => object { var $source_text; // the source text var $source_language_id; // the language of yout text var $category_id; // the category var $comment; // your comment about this text var $name; // the name of your text var $url_photo; // An image URL to show to the translator } );
Paramètres de sortie :
Object { var createTextMultiReturn; // The unique ID of ths new created text }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created, and class textMulti is included */ /* First of all, creation of the multi block text. Each block consists of 3 parameters : • : "content" : The text to translate. Can not be empty. • : "title" : A short text to intruduce this bloc (ex: short description, meta title, ...). Optional. • : "identifier" : A hidden variable that will be useful with the translated text. Optional. Here id an exemple, with a three blocks translation of a product. */ $array_of_blocks = array ( array("identifier" => "15487","title"=>"Meta Title","content"=>"The title of my product"), array("identifier" => "1548","title"=>"Short description","content"=>"A short description on my product"), array("identifier" => "45896","title"=>"Description","content"=>"A long description on my product, with more text ...") ); /* Now, Json encoding of my well formated array. NOTE : use json_encode options to ensure proper encoding of texts */ $encoded_string_of_blocks = json_encode($array_of_blocks, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); $text = new text(); $text->source_text = $encoded_string_of_blocks; // My Json encoded string representing array of blocks $text->source_language_id = 38; // corresponding to english language $text->category_id = 55; // category "fashion, clothing, jewelry" $text->comment = "a comment"; $text->name = "a title"; $text->url_photo = "http://www.domain.com/images/an_image.gif"; $my_text_id = $sClient->createTextMulti (array ('token'=> $token, 'text' => $text));
Retourne les informations sur une traduction utilisant le système des blocs, lorsqu'elle est terminée.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'id' => $translation_id, // your translation's id 'html' => $html // optional : if true, the fonction return the translation including html tags );
Paramètres de sortie :
Object { var ready; // boolean : true if the translation is finish, false otherwise object getTranslationInfoReturn { var idTranslation; // your translation's id var idLanguage; // your translation's language id var outputText; // the Json encoded translated array of blocks } }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created, and translation class included */ $translationId = 123; // The ID of your translation $result = $sClient->getTranslationMultiInfo (array ('token'=> $token, 'id' => $translationId)); if ($result->ready) { $myTranslation = new translation(); $myEncodedTranslation = $result->getTranslationMultiInfoReturn; $myDecodedTranslation = json_decode($myEncodedTranslation->{"outputText"}) }
Retourne la liste des catégories Dixit, sous la forme d'un tableau encodé avec Json.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'language_id' => $language_id, // The language in which you want the categories );
Paramètres de sortie :
Object { var getCategoriesReturn; // string : A Json encoded array containg the categories }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created */ $required_language = 48; // The ID of French language $result = $sClient->getCategories (array ('token'=> $token, 'language_id' => $required_language)); $in_array_result = json_decode($result->{"getCategoriesResult"}); echo ""; /* Will prints */ Array ( [0] => stdClass Object ( [categorie_id] => 37 [content] => Animaux ) [1] => stdClass Object ( [categorie_id] => 38 [content] => Architecture, Urbanisme, Art ) ... )".print_r($in_array_result,true)."
Retourne la liste des langues Dixit, sous la forme d'un tableau encodé avec Json.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'language_id' => $language_id, // The language in which you want the langauges );
Paramètres de sortie :
Object { var getLanguagesReturn; // string : A Json encoded array containg the languages }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created */ $required_language = 48; // The ID of French language $result = $sClient->getLanguages (array ('token'=> $token, 'language_id' => $required_language)); $in_array_result = json_decode($result->{"getLanguagesResult"}); echo ""; /* Will prints */ Array ( [0] => stdClass Object ( [language_id] => 8 [iso_code_2] => ar [content] => Arabe ) [1] => stdClass Object ( [language_id] => 15 [iso_code_2] => bg [content] => Bulgare ) ... )".print_r($in_array_result,true)."
Compte le nombre de mots d'un texte source.
Paramètres d'entrée :array ( 'token' => $token, // your connection token 'text' => object { var $source_text; // the source text => only mandatory element } );
Paramètres de sortie :
Object { var getWordCountReturn; // int : number of words in the text. }
Exemple d'utilisation :
/* Note : Suppose that $token and $sClient are created */ $text = new stdClass(); $text->source_text = "my source text"; $my_text_count = $sClient->getWordCount(array ('token'=> $token, 'text' => $text));
Types
Identifiants des langues
ID | Langue |
---|---|
33 | Allemand |
38 | Anglais (Royaume-Uni) |
192 | Anglais (USA) |
8 | Arabe |
19 | Bengali |
15 | Bulgare |
188 | Cantonais |
85 | Coréen |
60 | Croate |
32 | Danois |
40 | Espagnol |
190 | Espagnol (Amérique Latine) |
41 | Estonien |
45 | Finnois |
48 | Français |
191 | Français (Canada) |
37 | Grec |
58 | Hindi |
62 | Hongrois |
57 | Hébreu |
73 | Italien |
75 | Japonais |
100 | Letton |
98 | Lituanien |
184 | Mandarin |
119 | Norvégien |
117 | Néerlandais |
130 | Polonais |
132 | Portugais |
189 | Portugais (Brésilien) |
136 | Roumain |
137 | Russe |
151 | Serbe |
145 | Slovaque |
146 | Slovène |
155 | Suédois |
157 | Tamil |
28 | Tchèque |
160 | Thaï |
166 | Turc |
172 | Ukrainien |
176 | Vietnamien |
Identifiants des catégories
ID | Catégorie |
---|---|
37 | Animaux |
38 | Architecture, Urbanisme, Art |
39 | Assurances, Finances |
40 | Astrologie |
41 | Automobiles, Mécanique |
45 | Bijoux, horlogerie |
42 | Bâtiment, Industrie |
43 | Correspondance, Curriculum Vitae, Lettre de motivation |
44 | Culinaire, Œnologie |
46 | E-commerce |
47 | Electronique, Electrique, Energie |
48 | Environnement, Nature |
49 | Immobilier |
50 | Informatique, Technologie, Jeux vidéos |
51 | Littérature, presse |
52 | Marketing, Publicité, Relations Publiques |
55 | Mode, textile |
54 | Musique |
56 | Navigation, Maritime |
53 | Para-pharmacie, Cosmétiques |
57 | Politique, Economie |
58 | Religion, Histoire, Archéologie, |
59 | Sciences |
60 | Sport |
61 | Tourisme, Voyages |
62 | Transport, logistique |