Beispiel #1
0
        public static List <Schemas.Rest.@event> GetEvents(this Facebook facebook, string userId, string[] eventIds, int?startTime, int?endTime, RsvpStatus?rsvpStatus, IDictionary <string, string> parameters)
        {
            if (parameters == null)
            {
                parameters = new Dictionary <string, string>();
            }

            if (!string.IsNullOrEmpty(userId))
            {
                parameters.Add("uid", userId);
            }

            var eids = FacebookUtils.ToCommaSeperatedValues(eventIds);

            if (!string.IsNullOrEmpty(eids))
            {
                parameters.Add("eids", eids);
            }

            if (startTime != null)
            {
                parameters.Add("start_time", startTime.Value.ToString());
            }

            if (endTime != null)
            {
                parameters.Add("end_time", endTime.Value.ToString());
            }

            if (rsvpStatus != null)
            {
                parameters.Add("rsvp_status", FacebookUtils.ToString(rsvpStatus.Value));
            }

            var result = facebook.GetUsingRestApi("events.get", parameters);

            return(result.Equals("{}", StringComparison.OrdinalIgnoreCase)
                       ? new List <Schemas.Rest.@event>()
                       : FacebookUtils.DeserializeObject <List <Schemas.Rest.@event> >(result));
        }
        /// <summary>
        /// Gets the profile picture url for the specified id. Passing the access token.
        /// </summary>
        /// <param name="facebook">
        /// The facebook.
        /// </param>
        /// <param name="pictureSizeType">
        /// The picture size type.
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="FacebookException">
        /// </exception>
        /// <exception cref="FacebookRequestException">
        /// </exception>
        /// <remarks>
        /// This is useful in web pages, if you don't want to show the access token on the client side,
        /// or html page.
        /// </remarks>
        public static string GetProfilePictureUrlSafe(this Facebook facebook, string profileId, PictureSizeType?pictureSizeType)
        {
            var request = new RestRequest("/" + profileId + "/picture", Method.GET);

            if (pictureSizeType != null)
            {
                request.AddParameter("type", FacebookUtils.ToString(pictureSizeType.Value));
            }

            var response = facebook.ExecuteGraphApi(request, true, facebook.Settings.UserAgent);

            if (response.ResponseStatus == ResponseStatus.Completed)
            {
                var fbException = (FacebookException)response.Content;
                if (fbException != null)
                {
                    throw fbException;
                }

                return(response.ResponseUri.ToString());
            }

            throw new FacebookRequestException(response);
        }