Guide de démarrage

L'API dixit fonctionne avec le système de web-service SOAP et du protocole HTTP. Le processus d'intégration de cette API à votre interface ou à votre CMS est extrêmement simple.

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.

Par exemple en PHP :
$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()

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;
getTranslationInfo()

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;
}
getTextInfo()

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;
}
createText()

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));

createTranslation()

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) */

getBalance()

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;
getTextDetail()

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" 
			} 
		} 
	} 
}
*/
createTextMulti()

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));

getTranslationMultiInfo()

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"})
}
getCategories()

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 "
".print_r($in_array_result,true)."
"
; /* Will prints */ Array ( [0] => stdClass Object ( [categorie_id] => 37 [content] => Animaux ) [1] => stdClass Object ( [categorie_id] => 38 [content] => Architecture, Urbanisme, Art ) ... )
getLanguages()

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 "
".print_r($in_array_result,true)."
"
; /* 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 ) ... )
getWordCount()

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
33Allemand
38Anglais (Royaume-Uni)
192Anglais (USA)
8Arabe
19Bengali
15Bulgare
188Cantonais
85Coréen
60Croate
32Danois
40Espagnol
190Espagnol (Amérique Latine)
41Estonien
45Finnois
48Français
191Français (Canada)
37Grec
58Hindi
62Hongrois
57Hébreu
73Italien
75Japonais
100Letton
98Lituanien
184Mandarin
119Norvégien
117Néerlandais
130Polonais
132Portugais
189Portugais (Brésilien)
136Roumain
137Russe
151Serbe
145Slovaque
146Slovène
155Suédois
157Tamil
28Tchèque
160Thaï
166Turc
172Ukrainien
176Vietnamien

Identifiants des catégories

ID Catégorie
37Animaux
38Architecture, Urbanisme, Art
39Assurances, Finances
40Astrologie
41Automobiles, Mécanique
45Bijoux, horlogerie
42Bâtiment, Industrie
43Correspondance, Curriculum Vitae, Lettre de motivation
44Culinaire, Œnologie
46E-commerce
47Electronique, Electrique, Energie
48Environnement, Nature
49Immobilier
50Informatique, Technologie, Jeux vidéos
51Littérature, presse
52Marketing, Publicité, Relations Publiques
55Mode, textile
54Musique
56Navigation, Maritime
53Para-pharmacie, Cosmétiques
57Politique, Economie
58Religion, Histoire, Archéologie,
59Sciences
60Sport
61Tourisme, Voyages
62Transport, logistique