Example #1
0
        public static string GetClientList(Config config, out List <FBClient> arrClients, string oAuthConsumerKey, string oAuthSecret, int perPage, int page)
        {
            arrClients = new List <FBClient>();
            Hashtable ht = new Hashtable();

            ht.Add("folder", "active");
            if (perPage > 0)
            {
                ht.Add("per_page", perPage);
            }
            if (page > 0)
            {
                ht.Add("page", page);
            }
            XmlTextReader xmlReader = null;
            string        result    = FBRequest(config, "client.list", ht, out xmlReader, oAuthConsumerKey, oAuthSecret, "");

            if (result == "ok")
            {
                int      pageNumber = 1;
                FBClient fbClient   = new FBClient();
                while (xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlReader.Name)
                        {
                        case "clients":
                            pageNumber = GetPagesCount(xmlReader);
                            break;

                        case "client":
                            fbClient = new FBClient();
                            break;

                        case "client_id":
                            fbClient.ClientID = GetXMLTextNodeValueInt(xmlReader);
                            break;

                        case "organization":
                            fbClient.OrgName = GetXMLTextNodeValueStr(xmlReader);
                            break;
                        }
                    }
                    else if (xmlReader.NodeType == XmlNodeType.EndElement &&
                             xmlReader.Name == "client")
                    {
                        arrClients.Add(fbClient);
                    }
                }
                if (pageNumber > page)
                {
                    arrClients.Add(new FBClient(-(page + 1), "More..."));
                }
            }
            return(result);
        }
Example #2
0
 public static string GetClientList(Config config, out List<FBClient> arrClients, string oAuthConsumerKey, string oAuthSecret, int perPage, int page)
 {
     arrClients = new List<FBClient>();
     Hashtable ht = new Hashtable();
     ht.Add("folder", "active");
     if (perPage > 0)
     {
         ht.Add("per_page", perPage);
     }
     if (page > 0)
     {
         ht.Add("page", page);
     }
     XmlTextReader xmlReader = null;
     string result = FBRequest(config, "client.list", ht, out xmlReader, oAuthConsumerKey, oAuthSecret, "");
     if (result == "ok")
     {
         int pageNumber = 1;
         FBClient fbClient = new FBClient();
         while (xmlReader.Read())
         {
             if (xmlReader.NodeType == XmlNodeType.Element)
             {
                 switch (xmlReader.Name)
                 {
                     case "clients":
                         pageNumber = GetPagesCount(xmlReader);
                         break;
                     case "client":
                         fbClient = new FBClient();
                         break;
                     case "client_id":
                         fbClient.ClientID = GetXMLTextNodeValueInt(xmlReader);
                         break;
                     case "organization":
                         fbClient.OrgName = GetXMLTextNodeValueStr(xmlReader);
                         break;
                 }
             }
             else if (xmlReader.NodeType == XmlNodeType.EndElement
                && xmlReader.Name == "client")
             {
                 arrClients.Add(fbClient);
             }
         }
         if (pageNumber > page)
         {
             arrClients.Add(new FBClient(-(page + 1), "More..."));
         }
     }
     return result;
 }