Example #1
0
        public List<string> GetAllProfileUrls(int userId)
        {
            Transport transport = new Transport();
            NameValueCollection data = new NameValueCollection();
            data["owner_id"] = userId.ToString();
            data["rev"] = "1";
            data["access_token"] = m_SessionInfo.AccessToken;
            string response = transport.MakePostRequest("photos.getProfile", data);

            int errorCode = Transport.GetErrorCode(response);
            if (errorCode != 0)
            {
                throw new Exception("Unexpected error");
            }

            List<string> result = new List<string>();

            JToken root = JObject.Parse(response)["response"];
            JArray items = (JArray)root["items"];

            foreach (var item in items)
            {
                string avatarUrl = (string)item["photo_604"];
                result.Add(avatarUrl);
            }

            return result;
        }
Example #2
0
        public byte[] GetAvatar(int userId)
        {
            Transport transport = new Transport();
            NameValueCollection data = new NameValueCollection();
            data["user_ids"] = userId.ToString();
            data["fields"] = "photo_max";
            string response = transport.MakePostRequest("users.get", data);
            JArray items = (JArray)JObject.Parse(response)["response"];

            string avatarUrl = (string)items[0]["photo_max"];
            return Transport.DownloadFile(avatarUrl);
        }
Example #3
0
 public List<User> Search(string query, UserSex sex, int year)
 {
     Transport transport = new Transport();
     NameValueCollection data = new NameValueCollection();
     data["q"] = query;
     data["count"] = "1000";
     data["country"] = "2"; //Ukraine
     data["city"] = "650"; //Dnipropetrovsk
     data["sex"] = ((int)sex).ToString();
     data["has_photo"] = "1";
     data["fields"] = "sex";
     if (year != 0)
     {
         data["birth_year"] = year.ToString();
     }
     data["access_token"] = m_SessionInfo.AccessToken;
     string response = transport.MakePostRequest("users.search", data);
     int errorCode = Transport.GetErrorCode(response);
     if (errorCode != 0)
     {
         throw new Exception("Unexpected error");
     }
     bool ignoreOverflow = year != 0;
     return ParseUsers(response, ignoreOverflow);
 }