Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Niels Kristiansen 166 posts 382 karma points
    Jun 04, 2013 @ 17:10
    Niels Kristiansen
    0

    Anyone tried to implement Ubivox XML-RPC

    Hi,

    I try to make a Ubivox subscribtion in Umbraco through Ubivox API, but they only have an example in Python and PHP. Anyone tried to make an integration into C#?

    Hope someone can help me on this :)

    /Niels

  • David Mc Nally 2 posts 22 karma points
    Jun 13, 2013 @ 14:25
    David Mc Nally
    0

    Hi Niels, 

    I'm sorry I'm not exactly answering your question, however we currently don't have any examples using C#. Another developer, Bo Mortensen, recently worked on a .NET implentation - maybe you can get input from him? 
    https://twitter.com/bo_mortensen/status/344021666302668800

    Regards,
    David, Ubivox

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jun 15, 2013 @ 00:40
    Bo Damgaard Mortensen
    0

    Hi David,

    Yes, I helped Niels implementing it at CodeGarden '13 :-) It was easy to implement using the xml-rpc.net library!

    I'll trick Niels into sharing the code here (og perhaps send it to me, so I can paste it) for future reference.

    All the best,

    Bo

  • David Mc Nally 2 posts 22 karma points
    Jun 17, 2013 @ 11:08
    David Mc Nally
    0

    Great to hear - we're looking forward to that! :)

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jun 24, 2013 @ 11:18
    Bo Damgaard Mortensen
    2

    What comes around, goes around ;-)

    Here's some source code for the integration:

    First, we need to define our interface for the Ubivox methods:

    [XmlRpcUrl("https://yourclientnamehere.clients.ubivox.com/xmlrpc/")]
        public interface IUbivox : IXmlRpcProxy
        {
            [XmlRpcMethod("ubivox.create_subscription_with_data")]
            bool CreateNewSubscriptionWithData(string email_address, object[] lists, bool optin, XmlRpcStruct data);
        }

    Then we need a reference in our class file which are going to implement/use this interface, to the CookComputing.XmlRpc (which is already in the Umbraco /bin folder):

    using CookComputing.XmlRpc;

    Then we can use the interface by utilizing some of the methods, classes and properties of the XmlRpc assembly:

    // Create a new proxy using the interface we have defined
    var proxy = XmlRpcProxyGen.Create<IUbivox>();

    // Authenticate proxy.Credentials = new NetworkCredential(ubivoxUsername, ubivoxPassword);

    // Create a new XmlRpcStruct for the custom data fields on our Ubivox list
    XmlRpcStruct data = new XmlRpcStruct();

    // Fill in custom data fields
    // First string param is the field alias (found in Ubivox admin section) and last string param is the actual value
    data.Add("Name", "Bo Damgaard Mortensen"); data.Add("Zipcode", "8930"); data.Add("Company", "uconsult"); data.Add("Member", "Ja"); // Ubivox radiobutton: "Ja" / "Nej" ("Yes" / "No") data.Add("Gender", "Male");

    // Make call to Ubivox to insert a new subscriber with custom data fields
    var result = proxy.CreateNewSubscriptionWithData("info@uconsult.dk", new object[] { "ubivoxListId" }, false, data);

    Hope this helps :-)

    I am planning to create a C# wrapper/library in august where my holiday starts and build a Razor "API" package for Umbraco to make it easier to integrate Ubivox with C#/ASP.NET/Umbraco.

    All the best,

    Bo

  • Jan Borup Coyle 8 posts 51 karma points
    Jan 09, 2014 @ 00:59
    Jan Borup Coyle
    1

    It has taken me a long time to actually get this to work.

    I have been in dialog with Bo Damsgaard about this, and we try too get it work, but without result.

    I Need the subscribe code in a Razor environment, but it was not possible to implement the interface by Razor, so I get this Assembly to work instead.

    First the assembly:

    using System;
    using System.Net;
    using CookComputing.XmlRpc;

    namespace Chainbox.Umbraco47Site { [XmlRpcUrl("https://clientcompany.clients.ubivox.com/xmlrpc/")] public interface IUbivox : IXmlRpcProxy { [XmlRpcMethod("ubivox.createsubscriptionwithdata")] bool CreateNewSubscriptionWithData(string emailaddress, object[] lists, bool optin, XmlRpcStruct data); }

    public class Subscribe 
    {
    
        public string ubivoxUsername { get; set; }
        public string ubivoxPassword { get; set; }
        public string ubivoxError { get; set; }
    
        public Boolean SubscribeUser(string listid, string email, string name)
        {
            bool result = false;
            try
            {
                var proxy = XmlRpcProxyGen.Create<IUbivox>();
                proxy.Credentials = new NetworkCredential(ubivoxUsername, ubivoxPassword);
                XmlRpcStruct data = new XmlRpcStruct();
                data.Add("Navn", name);
                //data.Add("Zipcode", "8930");
                //data.Add("Company", "uconsult");
                //data.Add("Member", "Ja"); // Ubivox radiobutton: "Ja" / "Nej" ("Yes" / "No")
                //data.Add("Gender", "Male");
    
                // Make call to Ubivox to insert a new subscriber with custom data fields
                result = proxy.CreateNewSubscriptionWithData(email, new object[] { listid }, false, data);
            }
            catch (Exception ex)
            {
                ubivoxError = ex.Message;
            }
            return result;
        }
    }  
    

    }

    And here is the Razor-script:

    @using Chainbox.Umbraco47Site; @{ var UbivoxSubscribe = new Subscribe(); UbivoxSubscribe.ubivoxUsername = "spillehulen"; UbivoxSubscribe.ubivoxPassword = "1234567890"; var success = UbivoxSubscribe.SubscribeUser("156789", "john@doe.dk", "John Doe"); if(success) { } else { }
    }

    Hope other can use my example.

    Best regards

    Jan Borup Coyle.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies