Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Envoi de mails invite_participant en vb.

  • BilouMac
  • BilouMac's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago - 1 year 11 months ago #228670 by BilouMac
Aidez-nous à vous aider et remplissez les cases appropriées :
Votre version de LimeSurvey : Version 5.3.12+220502
Propre serveur
Thème :
LimeSurvey Fruity Theme
==================
Bonjour,
Je voudrai envoyer les mails aux nouveaux participants d'un questionnaire.
Les tid =21 et 22 sont bien des participants ayant déjà un code d'accès.
Tid 21 n'a pas encore d'invitation envoyée.
Tid 22 a déjà une invitation envoyée "manuellement".
Voici ma procédure:
Code:
Sub Envoi_Mail_LimeSurvey()
        Const baseUrl As String = "https://xxx.com/index.php/admin/remotecontrol"
        Dim sessionKey As SessionKey = baseUrl _
            .WithHeader("Content-type", "application/json").PostJsonAsync(New With {
            .method = "get_session_key",
            .params = New String() {"CodeUser", "MdpUser"},
            .id = 1
        }).Result.GetJsonAsync(Of SessionKey)().Result
        Console.WriteLine(sessionKey.result)
 
        Dim overrideAllConditions(2) As String
        overrideAllConditions(0) = "tid = 21"
        overrideAllConditions(1) = "tid = 22"
 
        Dim res = baseUrl _
            .WithHeader("Content-type", "application/json") _
            .PostJsonAsync(New With {
                .method = "invite_participant",
                .params = New Object() {sessionKey.result, "535611", overrideAllConditions, True}
        }).Result.GetJsonAsync().Result
 
 
    End Sub


Aucun mail ne part.
Avez-vous une idée ?
Merci.
Last edit: 1 year 11 months ago by BilouMac.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228709 by DenisChenu
Replied by DenisChenu on topic Envoi de mails invite_participant en vb.
Il y a moyen de faire
Console.WriteLine(res.result) ?
et d'avoir ce résultat ?

Sinon : invite_participant ne faite que inviter.
Tu as bien emailstatus = 'OK' pour ces 2 tokens ?

Difficile de répondre avec si peu d'informations

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • BilouMac
  • BilouMac's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228719 by BilouMac
Replied by BilouMac on topic Envoi de mails invite_participant en vb.
J'ai essayé:
Dim res = baseUrl _
.WithHeader("Content-type", "application/json") _
.PostJsonAsync(New With {
.method = "invite_participant",
.params = New Object() {sessionKey.result, "535611", overrideAllConditions, True}
}).Result.GetJsonAsync.Result

Console.WriteLine(res.result)

Mais cela me renvoit en erreur:
Exception non gérée : System.NullReferenceException: Variable objet ou variable d'un bloc With non définie.
à Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)
à Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object Arguments, String ArgumentNames, Type TypeArguments, Boolean CopyBack)

La méthode mail_registered_participants avait fonctionné, mais elle envoyait les mails d'inscription à tous les participants. Je n'ai pas réussi à envoyer les mails d'invitation aux participants n'ayant pas déjà reçu le mail (ou bien à un seul participant tid = 21 par exemple).

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228732 by DenisChenu
Replied by DenisChenu on topic Envoi de mails invite_participant en vb.
Bin,
Le truc c'est d'avoir l'erreur éventuelle retournée github.com/LimeSurvey/LimeSurvey/blob/a5...rol_handle.php#L2725 par exemple.

je sais pas le gérer avec VB

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • BilouMac
  • BilouMac's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago - 1 year 11 months ago #228773 by BilouMac
Replied by BilouMac on topic Envoi de mails invite_participant en vb.
J'ai trouvé un exemple en C#:
manual.limesurvey.org/RemoteControl_2_AP..._Paste_from_Forum.29

J'utilise donc son prog RPCclient.cs.

voici le code que j'essaie:
Code:
            string Baseurl = "https://xxx/index.php/admin/remotecontrol";
            JsonRPCclient client = new JsonRPCclient(Baseurl);
            client.Method = "get_session_key";
            client.Parameters.Add("username", "admin");
            client.Parameters.Add("password", "mdp");
            client.Post();
            string SessionKey = client.Response.result.ToString();
 
            client.ClearParameters();
            //Tableau de participants
            string Participants = new string[2] { "31", "32" };
            
            Newtonsoft.Json.Linq.JToken PartJson =Newtonsoft.Json.JsonConvert.SerializeObject(Participants);
 
 
            if (client.Response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //client.Method = "mail_registered_participants";
                //client.Parameters.Add("sSessionKey", SessionKey);
                //client.Parameters.Add("iSurveyID", 535611);
                //client.Parameters.Add("tid", 31);
                //client.Parameters.Add("bEmail", true);
 
                //client.Method = "list_participants";
                //client.Parameters.Add("sSessionKey", SessionKey);
                //client.Parameters.Add("iSurveyID", 535611);
                //client.Parameters.Add("iStart", 0);
                //client.Parameters.Add("iLimit", 100);
                //client.Parameters.Add("bUnused", true);
                //client.Parameters.Add("aAttributes", false);
 
                client.Method = "invite_participants";
                client.Parameters.Add("sSessionKey", SessionKey);
                client.Parameters.Add("iSurveyID", 535611);
                client.Parameters.Add("aTokenIds", PartJson);
                client.Parameters.Add("bEmail", true);
 
                Console.WriteLine("" );
                client.Post();
            }
 
            client.ClearParameters();
            Console.WriteLine("Part : " + Participants[0]);
            Console.WriteLine("Reponse :" + client.Response.result.ToString());
            //Console.ReadLine();



Voici la réponse que j'obtiens pour la méthode invite_participants:
Reponse :{
  "status": "Error: No candidate tokens"
}*
Alors que mes participants dont l'id est 33 ou 34 m'ont l'air corrects (je mets l'images en pj)

Pour info:
Pour la méthode mail_registered_participants, tous les participants reçoivent le mail de "Confirmation de votre participation à notre questionnaire".
La méthode list_participants m'affiche bien les informations des participants.
 
Attachments:
Last edit: 1 year 11 months ago by BilouMac.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Online
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228778 by DenisChenu
Replied by DenisChenu on topic Envoi de mails invite_participant en vb.
Essaye de supprime le True : github.com/LimeSurvey/LimeSurvey/blob/a5...okenDynamic.php#L183

ca semble pour sélectionner ceux qui ont reçus une invitation.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • BilouMac
  • BilouMac's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228786 by BilouMac
Replied by BilouMac on topic Envoi de mails invite_participant en vb.
J'ai essayé en mettant la ligne en commentaire et ensuite en mettant false à la place de true, mais j'ai toujours Error: No candidate tokens
J'ai l'impression de ne pas pouvoir passer le paramètre des tokenid.

Please Log in to join the conversation.

  • BilouMac
  • BilouMac's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228826 by BilouMac
Replied by BilouMac on topic Envoi de mails invite_participant en vb.
Pour info, j'ai réussi en mettant en commentaire:
client.Method = "invite_participants";
client.Parameters.Add("sSessionKey", SessionKey);
client.Parameters.Add("iSurveyID", 535611);
//client.Parameters.Add("aTokenIds", PartJson);
//client.Parameters.Add("bEmail", true);
Je n'ai pas le choix du participant à qui envoyer le mail, mais cela envoit le mail à tous ceux qui n'ont pas reçu le mail d'invitation. Et c'est ce que je veux que mon api fasse.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Moderators: Nickko

Lime-years ahead

Online-surveys for every purse and purpose