コード例 #1
0
        /// <summary>
        /// Retrieves the connections between the user the access token is for and
        /// another user. This corresponds to the friends.getConnection Hyves method.
        /// </summary>
        /// <param name="userId">The requested userId.</param>
        /// <returns>A list of connections; null if the call fails.</returns>
        public Collection <string> GetConnection(string userId)
        {
            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["userid"] = userId;

            HyvesResponse response = request.InvokeMethod(HyvesMethod.FriendsGetConnection);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                Collection <string> collection = new Collection <string>();
                Debug.Assert(response.Result is Hashtable);
                Hashtable result = (Hashtable)response.Result;

                Debug.Assert(result["connection"] is ArrayList);
                ArrayList list = (ArrayList)result["connection"];

                Debug.Assert(response.Result is Hashtable);
                Hashtable userIds = (Hashtable)list[0];

                Debug.Assert(result["connection"] is ArrayList);
                list = (ArrayList)userIds["userid"];

                for (int i = 0; i < list.Count; i++)
                {
                    collection.Add((string)list[i]);
                }

                return(collection);
            }

            return(null);
        }
        /// <summary>
        /// Gets the desired information about the specified tip. This corresponds to the
        /// tips.get Hyves method.
        /// </summary>
        /// <param name="tipIds">The requested tipIds.</param>
        /// <param name="responsefields">Get extra information from the tip.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified tip; null if the call fails.</returns>
        public Collection <Tip> GetTips(Collection <string> tipIds, HyvesTipResponsefield responsefields, bool useFancyLayout)
        {
            if (tipIds == null || tipIds.Count == 0)
            {
                throw new ArgumentNullException("tipIds");
            }

            StringBuilder tipIdBuilder = new StringBuilder();

            if (tipIds != null)
            {
                foreach (string id in tipIds)
                {
                    if (tipIdBuilder.Length != 0)
                    {
                        tipIdBuilder.Append(",");
                    }
                    tipIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["tipid"]             = tipIdBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.TipsGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Tip>("tip"));
            }

            return(null);
        }
        /// <summary>
        /// Creates respect for an tip. This corresponds to the
        /// tip.createRespect Hyves method.
        /// </summary>
        /// <param name="title">The title of the tip.</param>
        /// <param name="body">The body of the tip.</param>
        /// <param name="tipCategoryId">The identifier of a tip category.</param>
        /// <param name="rating">The rating of the tip.</param>
        /// <returns>True if the call succeeds, false if the call fails.</returns>
        public bool CreateTip(string title, string body, string tipCategoryId, int rating)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentException("title");
            }

            if (string.IsNullOrEmpty(body))
            {
                throw new ArgumentException("body");
            }

            if (string.IsNullOrEmpty(tipCategoryId))
            {
                throw new ArgumentException("tipCategoryId");
            }

            if (rating < 1 || rating > 5)
            {
                throw new ArgumentOutOfRangeException("rating", "The rating must be between 1 and 5.");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["title"]         = title;
            request.Parameters["body"]          = body;
            request.Parameters["tipcategoryid"] = tipCategoryId;
            request.Parameters["rating"]        = rating.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.TipsCreate);

            return(response.Status == HyvesResponseStatus.Succeeded);
        }
        /// <summary>
        /// Gets the desired information about the specified city. This corresponds to the
        /// cities.get Hyves method.
        /// </summary>
        /// <param name="cityIDs">The requested city IDs.</param>
        /// <returns>The information about the specified city; null if the call fails.</returns>
        public Collection <City> GetCities(Collection <string> cityIDs)
        {
            if ((cityIDs == null) || (cityIDs.Count == 0))
            {
                throw new ArgumentNullException("cityIDs");
            }

            StringBuilder cityIDBuilder = new StringBuilder();

            if (cityIDs != null)
            {
                foreach (string id in cityIDs)
                {
                    if (cityIDBuilder.Length != 0)
                    {
                        cityIDBuilder.Append(",");
                    }

                    cityIDBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["cityid"] = cityIDBuilder.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.CitiesGet);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <City>("city"));
            }

            return(null);
        }
        /// <summary>
        /// Gets the desired information about the specified www. This corresponds to the
        /// wwws.get Hyves method.
        /// </summary>
        /// <param name="wwwIDs">The requested wwwIDs.</param>
        /// <param name="responsefields">Get extra information from the requested www.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified www; null if the call fails.</returns>
        public Collection <Www> GetWwws(Collection <string> wwwIDs, HyvesWwwResponsefield responsefields, bool useFancyLayout)
        {
            if (wwwIDs == null || wwwIDs.Count == 0)
            {
                throw new ArgumentNullException("wwwIDs");
            }

            StringBuilder wwwIDBuilder = new StringBuilder();

            if (wwwIDs != null)
            {
                foreach (string id in wwwIDs)
                {
                    if (wwwIDBuilder.Length != 0)
                    {
                        wwwIDBuilder.Append(",");
                    }
                    wwwIDBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["wwwid"]             = wwwIDBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.WwwsGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Www>("www"));
            }

            return(null);
        }
        /// <summary>
        /// Gets the desired information about the specified hubCategory. This corresponds to the
        /// hubCategories.get Hyves method.
        /// </summary>
        /// <param name="hubCategoryId">The requested hubCategoryIds.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified hubCategory; null if the call fails.</returns>
        public Collection <HubCategory> GetHubCategories(Collection <string> hubCategoryIds, bool useFancyLayout)
        {
            if (hubCategoryIds == null || hubCategoryIds.Count == 0)
            {
                throw new ArgumentNullException("hubCategoryIds");
            }

            StringBuilder hubCategoryIdBuilder = new StringBuilder();

            if (hubCategoryIds != null)
            {
                foreach (string id in hubCategoryIds)
                {
                    if (hubCategoryIdBuilder.Length != 0)
                    {
                        hubCategoryIdBuilder.Append(",");
                    }
                    hubCategoryIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["hubcategoryid"] = hubCategoryIdBuilder.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.HubCategoriesGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <HubCategory>("hubcategory"));
            }

            return(null);
        }
コード例 #7
0
        /// <summary>
        /// Gets the desired information about the specified blog. This corresponds to the
        /// blogs.get Hyves method.
        /// </summary>
        /// <param name="blogIds">The requested blogIds.</param>
        /// <param name="responsefields">Get extra information from the blog.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified blog; null if the call fails.</returns>
        public Collection <Blog> GetBlogs(Collection <string> blogIds, HyvesBlogResponsefield responsefields, bool useFancyLayout)
        {
            if (blogIds == null || blogIds.Count == 0)
            {
                throw new ArgumentException("blogIds");
            }

            StringBuilder blogIdBuilder = new StringBuilder();

            if (blogIds != null)
            {
                foreach (string id in blogIds)
                {
                    if (blogIdBuilder.Length != 0)
                    {
                        blogIdBuilder.Append(",");
                    }
                    blogIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["blogid"]            = blogIdBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.BlogsGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Blog>("blog"));
            }

            return(null);
        }
        /// <summary>
        /// Gets the desired hub from the specified short name. This corresponds to the
        /// hubs.getByShortname Hyves method.
        /// </summary>
        /// <param name="shortName">The short name of the hub.</param>
        /// <param name="hubType">The tybe of hub to retrieve (leave empty for all hub types).</param>
        /// <param name="responsefields">Get extra information from the requested hub.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified hubs; null if the call fails.</returns>
        public Hub GetHubByShortName(string shortName, string hubType, HyvesHubResponsefield responsefields, bool useFancyLayout)
        {
            if (string.IsNullOrEmpty(shortName))
            {
                throw new ArgumentException("shortName cannot be null or empty.", "shortName");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["shortname"] = shortName;
            if (string.IsNullOrEmpty(hubType) == false)
            {
                request.Parameters["hubtype"] = hubType;
            }

            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.HubsGetByShortname, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessSingleItemResponse <Hub>("hub"));
            }

            return(null);
        }
        /// <summary>
        /// Gets the hub types. This corresponds to the
        /// hubs.getHubTypes Hyves method.
        /// </summary>
        /// <returns>The information about the hub types; null if the call fails.</returns>
        public Collection <string> GetHubTypes()
        {
            HyvesRequest request = new HyvesRequest(this.session);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.HubsGetHubTypes);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                Collection <string> collection = new Collection <string>();
                Debug.Assert(response.Result is Hashtable);
                Hashtable result = (Hashtable)response.Result;

                Debug.Assert(result["hubtype"] is ArrayList);
                ArrayList resultList = (ArrayList)result["hubtype"];

                for (int i = 0; i < resultList.Count; i++)
                {
                    collection.Add((string)resultList[i]);
                }

                return(collection);
            }

            return(null);
        }
コード例 #10
0
        /// <summary>
        /// Gets the desired information about the specified gadget. This corresponds to the
        /// gadgets.get Hyves method.
        /// </summary>
        /// <param name="gadgetId">The requested gadgetIds.</param>
        /// <param name="responsefields">Get extra information from the gadget.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified gadget; null if the call fails.</returns>
        public Collection <Gadget> GetGadgets(Collection <string> gadgetIds, HyvesGadgetResponsefield responsefields, bool useFancyLayout)
        {
            if (gadgetIds == null || gadgetIds.Count == 0)
            {
                throw new ArgumentNullException("gadgetIds");
            }

            StringBuilder gadgetIdBuilder = new StringBuilder();

            if (gadgetIds != null)
            {
                foreach (string id in gadgetIds)
                {
                    if (gadgetIdBuilder.Length != 0)
                    {
                        gadgetIdBuilder.Append(",");
                    }
                    gadgetIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["gadgetid"]          = gadgetIdBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Gadget>("gadget"));
            }

            return(null);
        }
コード例 #11
0
        /// <summary>
        /// Create a gadget for the current user. This corresponds to the
        /// gadgets.create Hyves method.
        /// </summary>
        /// <param name="title">The title of the gadget.</param>
        /// <param name="html">The html of the gadget.</param>
        /// <param name="visibility">The visibility of the gadget.</param>
        /// <param name="mayCopy">Allow to copy this gadget.</param>
        /// <returns>The new gadget; null if the call fails.</returns>
        public Gadget CreateGadget(string title, string html, HyvesVisibility visibility, bool mayCopy)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentNullException("title");
            }
            if (string.IsNullOrEmpty(html))
            {
                throw new ArgumentNullException("html");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["title"]      = title;
            request.Parameters["html"]       = html;
            request.Parameters["visibility"] = EnumHelper.GetDescription(visibility);
            request.Parameters["maycopy"]    = mayCopy.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.GadgetsCreate);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessSingleItemResponse <Gadget>("gadget"));
            }

            return(null);
        }
コード例 #12
0
        /// <summary>
        /// Gets the desired media. This corresponds to the media.get Hyves method.
        /// </summary>
        /// <param name="mediaIds">The list of requested media IDs.</param>
        /// <param name="responsefields">Get extra information from the media.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the desired media; null if the call fails.</returns>
        public Collection <Media> GetMedia(Collection <string> mediaIds, HyvesMediaResponsefield responsefields, bool useFancyLayout)
        {
            if (mediaIds == null || mediaIds.Count == 0)
            {
                throw new ArgumentNullException("mediaIds");
            }

            StringBuilder mediaIdBuilder = new StringBuilder();

            if (mediaIds != null)
            {
                foreach (string id in mediaIds)
                {
                    if (mediaIdBuilder.Length != 0)
                    {
                        mediaIdBuilder.Append(",");
                    }
                    mediaIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["mediaid"]           = mediaIdBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.MediaGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Media>("media"));
            }

            return(null);
        }
コード例 #13
0
        /// <summary>
        /// Adds a list of coma separated tags to a media. This corresponds to the
        /// media.addTag Hyves method.
        /// </summary>
        /// <param name="mediaId">The identifier for the media.</param>
        /// <param name="tags">A list of tags.</param>
        /// <returns>True if the call succeeds, false if the call fails.</returns>
        public bool AddTag(string mediaId, Collection <string> tags)
        {
            if (string.IsNullOrEmpty(mediaId))
            {
                throw new ArgumentException("mediaId");
            }

            StringBuilder tagsStringBuilder = new StringBuilder();

            foreach (string tag in tags)
            {
                tagsStringBuilder.Append(tag);
                tagsStringBuilder.Append(",");
            }

            tagsStringBuilder.Remove(tagsStringBuilder.Length - 1, 1);

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["mediaid"] = mediaId;
            request.Parameters["tag"]     = tagsStringBuilder.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.MediaAddTag);

            return(response.Status == HyvesResponseStatus.Succeeded);
        }
コード例 #14
0
        /// <summary>
        /// Gets the public media for the loggedin user. This corresponds to the
        /// media.getPublic Hyves method.
        /// </summary>
        /// <param name="sortType">The sorttype</param>
        /// <param name="mediaType">The media type of the results.</param>
        /// <param name="timeSpan">The timespan to select from.</param>
        /// <param name="responsefields">Get extra information from the media.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <param name="page">The requested page.</param>
        /// <param name="resultsPerPage">The number of results per page.</param>
        /// <returns>The information about the specified media; null if the call fails.</returns>
        public Collection <Media> GetPublic(HyvesSortType sortType, HyvesMediaType mediaType, HyvesTimeSpan timeSpan, HyvesMediaResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage)
        {
            if (sortType == HyvesSortType.NotSpecified)
            {
                throw new ArgumentOutOfRangeException("sortType");
            }

            if (mediaType == HyvesMediaType.Unknown)
            {
                throw new ArgumentOutOfRangeException("mediaType");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["sorttype"]  = EnumHelper.GetDescription(sortType);
            request.Parameters["mediatype"] = EnumHelper.GetDescription(mediaType);
            if (timeSpan == HyvesTimeSpan.NotSpecified)
            {
                request.Parameters["timespan"] = EnumHelper.GetDescription(timeSpan);
            }

            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.MediaGetPublic, useFancyLayout, page, resultsPerPage);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Media>("media"));
            }

            return(null);
        }
コード例 #15
0
        /// <summary>
        /// Revokes all accesstokens for user. This corresponds to the
        /// auth.revoke Hyves method.
        /// </summary>
        /// <param name="userId">The identifier of the user.</param>
        /// <returns>The number of tokens that were rovoked.</returns>
        public int Revoke(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException("userId");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["userid"] = userId;

            HyvesResponse response = request.InvokeMethod(HyvesMethod.AuthRevoke);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                Debug.Assert(response.Result is Hashtable);
                Hashtable result = (Hashtable)response.Result;

                Debug.Assert(result["deletecount"] is int);

                return((int)result["deletecount"]);
            }

            return(-1);
        }
        /// <summary>
        /// Gets the desired information about the specified users. This corresponds to the
        /// users.get Hyves method.
        /// </summary>
        /// <param name="usernames">The list of requested usernames.</param>
        /// <param name="responsefields">Get extra information from the requested user</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified users; null if the call fails.</returns>
        public Collection <User> GetUsersByUserName(Collection <string> usernames, HyvesUserResponsefield responsefields, bool useFancyLayout)
        {
            if ((usernames == null) || (usernames.Count == 0))
            {
                throw new ArgumentNullException("usernames");
            }

            StringBuilder usernameBuilder = new StringBuilder();

            if (usernames != null)
            {
                foreach (string name in usernames)
                {
                    if (usernameBuilder.Length != 0)
                    {
                        usernameBuilder.Append(",");
                    }
                    usernameBuilder.Append(name);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["username"]          = usernameBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields, HyvesUserPrivateResponsefield.None);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.UsersGetByUsername, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <User>("user"));
            }

            return(null);
        }
コード例 #17
0
        /// <summary>
        /// Send a private message to multiple targets. This corresponds to the
        /// messages.send Hyves method.
        /// </summary>
        /// <param name="title">Title of the message.</param>
        /// <param name="body">Body of the message.</param>
        /// <param name="targetUserId">A single user.</param>
        /// <returns><b>true</b> if successfull; otherwise <b>false</b>.</returns>
        /// <remarks>Spam sensitive method (for trusted partners only).</remarks>
        public bool SendMessage(string title, string body, string targetUserId)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentNullException("title");
            }
            if (string.IsNullOrEmpty(body))
            {
                throw new ArgumentNullException("body");
            }
            if (string.IsNullOrEmpty(targetUserId))
            {
                throw new ArgumentNullException("targetUserId");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["title"]         = title;
            request.Parameters["body"]          = body;
            request.Parameters["target_userid"] = targetUserId;

            HyvesResponse response = request.InvokeMethod(HyvesMethod.MessagesSend);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Send an email to an given userid which has to be loggedin user
        /// or a friend of logged in user. This corresponds to the
        /// users.sendNotificationToFriend Hyves method.
        /// </summary>
        /// <param name="userid">A single userid.</param>
        /// <param name="subject">Subject of the email.</param>
        /// <param name="body">Body of the email. </param>
        /// <param name="senderName">Sender name. </param>
        /// <param name="senderEmail">Sender email address.</param>
        /// <returns><b>True</b> if the call succeeds, otherwise <b>false</b>.</returns>
        /// <remarks>Spam sensitive method (for trusted partners only).</remarks>
        public bool SendNotificationToFriend(string userId, string subject, string body, string senderName, string senderEmail)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentNullException("userId");
            }
            if (string.IsNullOrEmpty(subject))
            {
                throw new ArgumentNullException("subject");
            }
            if (string.IsNullOrEmpty(body))
            {
                throw new ArgumentNullException("body");
            }
            if (string.IsNullOrEmpty(senderName))
            {
                throw new ArgumentNullException("senderName");
            }
            if (string.IsNullOrEmpty(senderEmail))
            {
                throw new ArgumentNullException("senderEmail");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["userid"]       = userId;
            request.Parameters["subject"]      = subject;
            request.Parameters["body"]         = body;
            request.Parameters["sender_name"]  = senderName;
            request.Parameters["sender_email"] = senderEmail;

            HyvesResponse response = request.InvokeMethod(HyvesMethod.UsersSendNotificationToFriend);

            return(response.Status == HyvesResponseStatus.Succeeded);
        }
コード例 #19
0
        public bool RemoveMediaFromAlbum(string albumId, Collection <string> mediaIds)
        {
            if (string.IsNullOrEmpty(albumId))
            {
                throw new ArgumentException("albumId");
            }

            if (mediaIds == null)
            {
                throw new ArgumentNullException("mediaIds");
            }

            StringBuilder mediaIdBuilder = new StringBuilder();

            foreach (string id in mediaIds)
            {
                if (mediaIdBuilder.Length != 0)
                {
                    mediaIdBuilder.Append(",");
                }

                mediaIdBuilder.Append(id);
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["albumid"] = albumId;
            request.Parameters["mediaid"] = mediaIdBuilder.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.AlbumsRemoveMedia);

            return(response.Status == HyvesResponseStatus.Succeeded);
        }
        /// <summary>
        /// Gets the desired listeners from the specified type. This corresponds to the
        /// listeners.getByType Hyves method.
        /// </summary>
        /// <param name="type">Type of listeners to retrieve.</param>
        /// <returns>The information about the specified listener; null if the call fails.</returns>
        public Collection <Listener> GetListenersByType(HyvesListenerType type)
        {
            if (type == HyvesListenerType.NotSpecified)
            {
                throw new ArgumentNullException("type");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            switch (type)
            {
            case HyvesListenerType.AccesstokenRevoke:
                request.Parameters["type"] = "accesstoken_revoke";
                break;
            }

            HyvesResponse response = request.InvokeMethod(HyvesMethod.ListenersGetByType, false);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Listener>("listener"));
            }

            return(null);
        }
コード例 #21
0
        /// <summary>
        /// Retrieve public blogs. This corresponds to the blogs.getPublic Hyves method.
        /// </summary>
        /// <param name="sortType">The sort type.</param>
        /// <param name="timeSpan">The timespan to select from.</param>
        /// <returns>The information about the blogs; null if the call fails.</returns>
        public Collection <Blog> GetPublicBlogs(HyvesSortType sortType, HyvesTimeSpan timeSpan, HyvesBlogResponsefield responsefields, bool useFancyLayout)
        {
            if (sortType == HyvesSortType.NotSpecified)
            {
                throw new ArgumentOutOfRangeException("sortType");
            }

            if (timeSpan == HyvesTimeSpan.NotSpecified)
            {
                throw new ArgumentOutOfRangeException("timeSpan");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["sorttype"]          = EnumHelper.GetDescription(sortType);
            request.Parameters["timespan"]          = EnumHelper.GetDescription(timeSpan);
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.BlogsGetForFriends, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Blog>("blog"));
            }

            return(null);
        }
        /// <summary>
        /// Create a new listener for the ApiConsumer. This corresponds to the
        /// listener.create Hyves method.
        /// </summary>
        /// <param name="type">Type of listener to create.</param>
        /// <param name="callback">Url to do the callback to.</param>
        /// <returns>The new listener; null if the call fails.</returns>
        public Listener CreateListener(HyvesListenerType type, string callback)
        {
            if (type == HyvesListenerType.NotSpecified)
            {
                throw new ArgumentException("type");
            }

            if (string.IsNullOrEmpty(callback))
            {
                throw new ArgumentException("callback");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            switch (type)
            {
            case HyvesListenerType.AccesstokenRevoke:
                request.Parameters["type"] = "accesstoken_revoke";
                break;
            }

            request.Parameters["callback"] = callback;

            HyvesResponse response = request.InvokeMethod(HyvesMethod.ListenersCreate);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessSingleItemResponse <Listener>("listener"));
            }

            return(null);
        }
        /// <summary>
        /// Search in public wwws. This corresponds to the
        /// wwws.searchPublic Hyves method.
        /// </summary>
        /// <param name="searchterms">The search terms.</param>
        /// <param name="scopeMinId">Only www's posted after this one will be received.</param>
        /// <param name="scopeMaxId">Only www's posted before this one will be received.</param>
        /// <param name="limit">The maximum number of results desired.</param>
        /// <param name="responsefields">Get extra information from the requested www.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified www; null if the call fails.</returns>
        public Collection <Www> SearchPublic(string searchterms, string scopeMinId, string scopeMaxId, int limit, HyvesWwwResponsefield responsefields, bool useFancyLayout)
        {
            HyvesRequest request = new HyvesRequest(this.session);

            if (string.IsNullOrEmpty(searchterms) == false)
            {
                request.Parameters["searchterms"] = searchterms;
            }

            if (string.IsNullOrEmpty(scopeMinId) == false)
            {
                request.Parameters["scope_minid"] = scopeMinId;
            }

            if (string.IsNullOrEmpty(scopeMaxId) == false)
            {
                request.Parameters["scope_maxid"] = scopeMaxId;
            }

            if (limit > 0)
            {
                request.Parameters["limit"] = limit.ToString();
            }

            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.WwwsSearchPublic, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Www>("www"));
            }

            return(null);
        }
        /// <summary>
        /// Deletes a listener for the ApiConsumer. This corresponds to the
        /// listener.create Hyves method.
        /// </summary>
        /// <param name="listenerId">The requested listenerId.</param>
        /// <returns>The new listener; null if the call fails.</returns>
        public bool DeleteListener(string listenerId)
        {
            if (string.IsNullOrEmpty(listenerId))
            {
                throw new ArgumentException("listenerId");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["listenerid"] = listenerId;

            HyvesResponse response = request.InvokeMethod(HyvesMethod.ListenersCreate);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                Debug.Assert(response.Result is Hashtable);
                Hashtable result = (Hashtable)response.Result;

                Debug.Assert(result["success"] is bool);

                return((bool)result["success"]);
            }

            return(false);
        }
        /// <summary>
        /// Gets the desired information about the specified region. This corresponds to the
        /// regions.get Hyves method.
        /// </summary>
        /// <param name="regionIDs">The requested region IDs.</param>
        /// <returns>The information about the specified region; null if the call fails.</returns>
        public Collection <Region> GetRegions(Collection <string> regionIDs)
        {
            if ((regionIDs == null) || (regionIDs.Count == 0))
            {
                throw new ArgumentNullException("regionIDs");
            }

            StringBuilder regionIDBuilder = new StringBuilder();

            if (regionIDs != null)
            {
                foreach (string id in regionIDs)
                {
                    if (regionIDBuilder.Length != 0)
                    {
                        regionIDBuilder.Append(",");
                    }
                    regionIDBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["regionid"] = regionIDBuilder.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.RegionsGet);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Region>("region"));
            }

            return(null);
        }
        /// <summary>
        /// Gets the desired information about the specified listener. This corresponds to the
        /// listeners.get Hyves method.
        /// </summary>
        /// <param name="listenerId">The requested listenerIds.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified listener; null if the call fails.</returns>
        public Collection <Listener> GetListeners(Collection <string> listenerIds)
        {
            if (listenerIds == null || listenerIds.Count == 0)
            {
                throw new ArgumentNullException("listenerIds");
            }

            StringBuilder listenerIdBuilder = new StringBuilder();

            if (listenerIds != null)
            {
                foreach (string id in listenerIds)
                {
                    if (listenerIdBuilder.Length != 0)
                    {
                        listenerIdBuilder.Append(",");
                    }
                    listenerIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["listenerid"] = listenerIdBuilder.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.ListenersGet, false);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Listener>("listener"));
            }

            return(null);
        }
        /// <summary>
        /// Gets the desired tips from the specified user by user. This corresponds to the
        /// tips.getByUser Hyves method.
        /// </summary>
        /// <param name="userId">The requested user Id.</param>
        /// <param name="tipCategoryId">Filter selecting tips by tip category ID.</param>
        /// <param name="responsefields">Get extra information from the tip.</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <param name="page">The requested page.</param>
        /// <param name="resultsPerPage">The number of results per page.</param>
        /// <returns>The information about the specified tip; null if the call fails.</returns>
        public Collection <Tip> GetTipsByUser(string userId, string tipCategoryId, HyvesTipResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage)
        {
            if (string.IsNullOrEmpty(userId))
            {
                throw new ArgumentException("userId");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["userid"] = userId;
            if (string.IsNullOrEmpty(tipCategoryId) == false)
            {
                request.Parameters["tipcategoryid"] = tipCategoryId;
            }

            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.TipsGetByUser, useFancyLayout, page, resultsPerPage);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Tip>("tip"));
            }

            return(null);
        }
コード例 #28
0
        /// <summary>
        /// Creates a ping. This corresponds to the
        /// pings.createByFriend Hyves method.
        /// </summary>
        /// <param name="targetUserId">The title of the ping.</param>
        /// <param name="pingTypeId">The identifier for a ping type.</param>
        /// <param name="body">The html of the ping.</param>
        /// <param name="visibility">The visibility of the ping.</param>
        /// <returns>The new ping; null if the call fails.</returns>
        /// <remarks>Hidden method (for any partner).</remarks>
        public Ping CreatePingByFriend(string targetUserId, string pingTypeId, string body, HyvesVisibility visibility)
        {
            if (string.IsNullOrEmpty(targetUserId))
            {
                throw new ArgumentException("targetUserId cannot be null or empty.", "targetUserId");
            }

            if (string.IsNullOrEmpty(pingTypeId) && string.IsNullOrEmpty(body))
            {
                throw new ArgumentException("Please enter a ping type or a body.");
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["target_userid"] = targetUserId;
            if (string.IsNullOrEmpty(body))
            {
                request.Parameters["pingtypeid"] = pingTypeId;
            }
            else
            {
                request.Parameters["body"] = body;
            }

            request.Parameters["visibility"] = EnumHelper.GetDescription(visibility);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.PingsCreateByFriend);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessSingleItemResponse <Ping>("ping"));
            }

            return(null);
        }
        /// <summary>
        /// Gets the desired information about the specified privatespots. This corresponds to the
        /// privatespots.get Hyves method.
        /// </summary>
        /// <param name="privatespotIds">The list of requested privatespot IDs.</param>
        /// <param name="responsefields">Get extra information from the requested privatespot</param>
        /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param>
        /// <returns>The information about the specified privatespots; null if the call fails.</returns>
        public Collection <PrivateSpot> GetPrivateSpots(Collection <string> privatespotIds, HyvesPrivateSpotResponsefield responsefields, bool useFancyLayout)
        {
            if ((privatespotIds == null) || (privatespotIds.Count == 0))
            {
                throw new ArgumentException("privatespotIds");
            }

            StringBuilder privatespotIdBuilder = new StringBuilder();

            if (privatespotIds != null)
            {
                foreach (string id in privatespotIds)
                {
                    if (privatespotIdBuilder.Length != 0)
                    {
                        privatespotIdBuilder.Append(",");
                    }
                    privatespotIdBuilder.Append(id);
                }
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["privatespotid"]     = privatespotIdBuilder.ToString();
            request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields);

            HyvesResponse response = request.InvokeMethod(HyvesMethod.PrivateSpotsGet, useFancyLayout);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <PrivateSpot>("privatespot"));
            }

            return(null);
        }
コード例 #30
0
        /// <summary>
        /// Gets the distance for given friend ids with the current user. This corresponds to the
        /// friends.getDistance Hyves method.
        /// </summary>
        /// <param name="userIds">The list of requested user Ids.</param>
        /// <returns>The information about the specified users; null if the call fails.</returns>
        public Collection <Distance> GetDistance(Collection <string> userIds)
        {
            if ((userIds == null) || (userIds.Count == 0))
            {
                throw new ArgumentNullException("userIds");
            }

            StringBuilder userIdBuilder = new StringBuilder();

            foreach (string id in userIds)
            {
                if (userIdBuilder.Length != 0)
                {
                    userIdBuilder.Append(",");
                }
                userIdBuilder.Append(id);
            }

            HyvesRequest request = new HyvesRequest(this.session);

            request.Parameters["userid"] = userIdBuilder.ToString();

            HyvesResponse response = request.InvokeMethod(HyvesMethod.FriendsGetDistance);

            if (response.Status == HyvesResponseStatus.Succeeded)
            {
                return(response.ProcessResponse <Distance>("distance"));
            }

            return(null);
        }