/// <summary>
        /// Fetches the connections for given object.
        /// </summary>
        /// <param name="facebook"></param>
        /// <param name="id">Id of the object to fetch.</param>
        /// <param name="connectionName">Name of the connection.</param>
        /// <param name="parameters">List of arguments.</param>
        /// <returns>Returns the connections.</returns>
        public static T GetConnections <T>(this Facebook facebook, string id, string connectionName,
                                           IDictionary <string, string> parameters)
        {
            var jsonString = GetConnections(facebook, id, connectionName, parameters);

            FacebookUtils.ThrowIfFacebookException(jsonString);
            return(FacebookUtils.DeserializeObject <T>(jsonString));
        }
Example #2
0
        /// <summary>
        /// Gets the specified post by id.
        /// </summary>
        /// <param name="facebook">
        /// The facebook.
        /// </param>
        /// <param name="postId">
        /// The id.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// </returns>
        public static Post GetPost(this Facebook facebook, string postId, IDictionary <string, string> parameters)
        {
            var json = facebook.GetPostAsJson(postId, parameters);

            // Facebook seemed to have changed the api on 9/15/2010. small hack to DeserializeObject properly.
            json = json.Replace("\"comments\":[]", "\"comments\":{data:null,count:0}");

            return(FacebookUtils.DeserializeObject <Post>(json));
        }
Example #3
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));
        }
Example #4
0
        /// <summary>
        /// Gets the page with specified id.
        /// </summary>
        /// <param name="facebook">
        /// The facebook.
        /// </param>
        /// <param name="pageId">
        /// The page id.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// </returns>
        public static Page GetPage(this Facebook facebook, string pageId, IDictionary <string, string> parameters)
        {
            var result = facebook.GetObject(pageId, parameters);

            return(FacebookUtils.DeserializeObject <Page>(result));
        }