Utilisation de l'API Vous trouverez dans cette rubrique des exemples d'appels à l'API dans différents langages de programmation. .NET // Get token AuthenticationServiceReference.AuthenticationTokenContext token = null try { // Authentication request AuthenticationServiceReference.AuthenticationServiceClient authClient = new Authentication.AuthenticationServiceClient("BasicHttpBinding_AuthenticationService")); AuthenticationServiceReference.AuthenticationRequest req = new AuthenticationServiceReference.AuthenticationRequest(); req.AccountID = listId; req.AuthenticationKey = authenticationKey; AuthenticationServiceReference.AuthenticationTokenResponse res = authClient.GetAuthenticationToken(req); // Create token token = new AuthenticationServiceReference.AuthenticationTokenContext(); token.AccountID = listID; token.Key = res.Key; authClient.Close(); }catch (FaultException ex) { Console.WriteLine(ex.Detail.Ticket,ex.Detail.Description); } // Client SOAP 1.1 MessageServiceReference.MessageServiceClient client = new Dolist.EMT.Test.MessageServiceReference.MessageServiceClient("BasicHttpBinding_MessageService"); try { MessageServiceReference.SendMessageRequest message = new Dolist.EMT.Test.MessageServiceReference.SendMessageRequest(); message.Data = @" insérer les données variables xml (cf : Onglet envoi de test dans la partie modification de template) "; message.Recipient = "test@test.com"; // recipient email message.TemplateID = 0; // your template ID message.MessageContentType = Dolist.EMT.Test.MessageServiceReference.ContentType.EmailMultipart; // Add attachments List attachmentList = new List(); MailAttachment attachment = new MailAttachment(); attachment.FileExtension = FileExtension.JPEG; //your file extension attachment.FileName = "[Your file name]"; attachment.FileStream = Convert.ToBase64String(File.ReadAllBytes("[Your file path]")); attachmentList.Add(attachment); message.Attachments = attachmentList.ToArray(); //---------------------------------------- // request send message and get ticket string ticket = client.SendMessage(token, message); client.Close(); } catch (FaultException ex) { Console.WriteLine(ex.Detail.Ticket,ex.Detail.Description); } Tout Framework + web reference : Envoyer un message // Get token AuthenticationAsmxReference.AuthenticationTokenContext token = null; try { // Authentication request AuthenticationAsmxReference.AuthenticationService authClient = new AuthenticationAsmxReference.AuthenticationService(); AuthenticationAsmxReference.AuthenticationRequest req = new AuthenticationAsmxReference.AuthenticationRequest(); req.AccountID = listId; req.AuthenticationKey = authenticationKey; AuthenticationAsmxReference.AuthenticationTokenResponse res = authClient.GetAuthenticationToken(req); // create token token = new AuthenticationAsmxReference.AuthenticationTokenContext(); token.AccountID = listID; token.Key = res.Key; }catch(System.Web.Services.Protocols.SoapException ex){ Console.WriteLine(ex.Detail.OuterXml); } try { MessageAsmxReference.MessageService service = new Dolist.EMT.Test.MessageAsmxReference.MessageService(); MessageAsmxReference.SendMessageRequest request = new Dolist.EMT.Test.MessageAsmxReference.SendMessageRequest(); request.Data = @" insérer les données variables xml (cf : Onglet envoi de test dans la partie modification de template) "; request.Recipient = "test@test.com"; // recipient email request.TemplateID = 1; // your template ID request.MessageContentType = Dolist.EMT.Test.MessageAsmxReference.ContentType.EmailMultipart; // Add attachments List attachmentList = new List(); MailAttachment attachment = new MailAttachment(); attachment.FileExtension = FileExtension.JPEG; // Your file extension attachment.FileName = "[Your file name]"; attachment.FileStream = Convert.ToBase64String(File.ReadAllBytes("[Your file path]")); attachmentList.Add(attachment); message.Attachments = attachmentList.ToArray(); //---------------------------------------- service.SendMessage(token, request); } catch (System.Web.Services.Protocols.SoapException ex) { Console.WriteLine(ex.Detail.OuterXml); } PHP Envoyer un message : SOAP 1.1 1, 'location' => $location_auth)); $request_auth = array( 'authenticationRequest' => array( 'AuthenticationKey' => 'authentication_key', 'AccountID' => $AccountId ) ); // Authentication request $result_auth = $client_auth->GetAuthenticationToken($request_auth); if (!is_null($result_auth->GetAuthenticationTokenResult) and $result_auth->GetAuthenticationTokenResult != '') { if ($result_auth->GetAuthenticationTokenResult->Key != '') { echo "Authentification réussie."; $proxywsdl = "http://api.emt.dolist.net/V3/MessageService.svc?wsdl"; $client = new SoapClient($proxywsdl, array('soap_version' => SOAP_1_1, 'trace' => 1, 'location'=>"http://api.emt.dolist.net/V3/MessageService.svc/soap1.1" )); //add attachments $attachments[] = array("FileName"=>"test.txt","FileExtension"=>"TXT","FileStream"=>base64_encode_file("[Your file path]")); $message = array('Data'=>utf8_encode(' insérer les données variables xml (cf : Onglet envoi de test dans la partie modification de template) '), 'MessageContentType'=>'EmailMultipart', 'Recipient'=>'destinataire@domaine.com', 'TemplateID'=>1, 'Attachments'=> $attachments ); // Create token $token = array( 'AccountID' => $AccountId, 'Key' => $result_auth->GetAuthenticationTokenResult->Key ); $sendMessageParam = array('token' => $token, 'message'=>$message); // Send message $ticket = $client->SendMessage($sendMessageParam); echo "Message sent : Ticket -> "; echo $ticket->SendMessageResult; } } } // Error management catch(SoapFault $fault) { echo $fault; $detail=$fault->detail; echo "Error"; echo "Message : ".$detail->ServiceException->Message; echo " "; echo "Description : ".$detail->ServiceException->Description; echo ""; } function base64_encode_file ($file) { $fileBinary = fread(fopen($fileName, "r"), filesize($fileName)); return base64_encode($fileBinary); } ?>