Exemplo n.º 1
0
        public void GetMemberInbox()
        {
            Dictionary <string, string> messageHeaders = new Dictionary <string, string>();

            XmlHttpProvider provider = new XmlHttpProvider("https://api.yourmembership.com/");

            YMSDK.ApiManager manager = new YMSDK.ApiManager(provider);
            manager.ApiKeyPublic = "9FB80E52-49C5-4B31-9AE6-08D83F065897";
            manager.ApiKeySa     = "B4226439-485F-49EF-A183-37319519A0FA";
            manager.SaPasscode   = "04iHL9sU5g24";
            manager.Version      = "2.30";

            //Create session for the current user
            YMSDK.ApiResponse response = manager.SessionCreate();

            //Authenticate the user for the current session
            response = manager.AuthAuthenticate("vijaysaini", "priyank1");
            //response = manager.AuthAuthenticate("priyankmittal", "priyank1");

            if (response.ErrorCode == YMSDK.ApiErrorCode.NoError)
            {
                //Optional, store the ID or MemberID of the Authenticated User for later use
                string memberGuid = response.MethodResults.GetNamedItem("ID").Value;
                string memberID   = response.MethodResults.GetNamedItem("WebsiteID").Value;

                //Get Inbox messages for this user
                //response = manager.MemberProfileGet();
                var timestamp = DateTime.Now.ToString("yyyy-MM-dd HH mm ss");
                //2008 - 01 - 01 00:00:00
                response = manager.SaPeopleAllGetIDs(DateTime.Now, Convert.ToInt32(memberID));
                if (response.ErrorCode == YMSDK.ApiErrorCode.NoError)
                {
                    //Display the messages to the user
                    ApiMethodResults results = response.MethodResults;

                    if (results.Items.Count > 0)
                    {
                        foreach (DataItem message in results.Items)
                        {
                            messageHeaders.Add(
                                message.GetNamedItem("MessageID").Value,
                                message.GetNamedItem("Subject").Value
                                );
                        }
                    }
                }
            }

            //Console.WriteLine(string.Format("Fetched {0} messages.", messageHeaders.Count));
            Console.WriteLine(response);
            Console.ReadLine();
        }
Exemplo n.º 2
0
        public static DataItem AsDataItem(this ApiMethodResults results)
        {
            DataItem root = new DataItem();

            root.Name = "foo";

            foreach (DataItem subitem in results.Items)
            {
                root.Items.Add(subitem);
            }

            return(root);
        }
Exemplo n.º 3
0
        internal ApiMethodResults GetMethodResultsFromNode(XmlNode node)
        {
            ApiMethodResults results = new ApiMethodResults();
            DataItem         result;

            if (node.InnerXml.ContainsText())
            {
                results.ValueRaw = node.InnerXml;
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.NodeType == XmlNodeType.Element)
                {
                    result       = new DataItem();
                    result.Name  = child.Name;
                    result.Value = child.InnerText;                       //Note: changed to inner text b/c we want the unencoded value

                    foreach (XmlAttribute attr in child.Attributes)
                    {
                        result.AddAttribute(attr.Name, attr.Value);
                    }

                    foreach (XmlNode grandchild in child.ChildNodes)
                    {
                        if (grandchild.NodeType == XmlNodeType.Element)
                        {
                            if (grandchild.HasChildNodes)
                            {
                                result.Items.Add(GetDataItemFromXml(grandchild));
                            }
                            else
                            {
                                result.Items.Add(new DataItem()
                                {
                                    Name = grandchild.Name, Value = grandchild.InnerText
                                });
                            }
                        }
                    }

                    results.Items.Add(result);
                }
            }

            return(results);
        }