Ejemplo n.º 1
0
 protected GitHubResponse(SocialHttpResponse response)
 {
     RateLimit          = Int32.Parse(response.Headers["X-RateLimit-Limit"]);
     RateLimitRemaining = Int32.Parse(response.Headers["X-RateLimit-Remaining"]);
     RateLimitReset     = SocialUtils.GetDateTimeFromUnixTime(response.Headers["X-RateLimit-Reset"]);
     Response           = response;
 }
 /// <summary>
 /// Gets a comment from the specified <var>JsonObject</var>.
 /// </summary>
 /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
 public static InstagramComment Parse(JsonObject obj)
 {
     if (obj == null)
     {
         return(null);
     }
     return(new InstagramComment(obj)
     {
         Id = obj.GetLong("id"),
         Created = SocialUtils.GetDateTimeFromUnixTime(obj.GetLong("created_time")),
         Text = obj.GetString("text"),
         User = InstagramUserSummary.Parse(obj.GetObject("from"))
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a media from the specified <var>JsonObject</var>.
        /// </summary>
        /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
        public static InstagramMedia Parse(JsonObject obj)
        {
            if (obj == null)
            {
                return(null);
            }

            JsonObject comments = obj.GetObject("comments");
            JsonObject likes    = obj.GetObject("likes");

            string type = obj.GetString("type");

            InstagramMedia media = null;

            if (type == "image")
            {
                media = new InstagramImage(obj);
            }
            else if (type == "video")
            {
                media = new InstagramVideo(obj)
                {
                    Videos = obj.GetObject("videos", InstagramVideoSummary.Parse)
                };
            }

            if (media != null)
            {
                media.Id           = obj.GetString("id");
                media.Type         = type;
                media.Tags         = obj.GetArray("tags").Cast <string>();
                media.Created      = SocialUtils.GetDateTimeFromUnixTime(obj.GetInt64("created_time"));
                media.Link         = obj.GetString("link");
                media.Filter       = obj.GetString("filter");
                media.CommentCount = comments.GetInt32("count");
                media.Comments     = comments.GetArray("data", InstagramComment.Parse);
                media.LikeCount    = likes.GetInt32("count");
                media.Likes        = likes.GetArray("data", InstagramUserSummary.Parse);
                media.Images       = obj.GetObject("images", InstagramImageSummary.Parse);
                media.Caption      = obj.GetObject("caption", InstagramComment.Parse);
                media.User         = obj.GetObject("user", InstagramUser.Parse);
                media.Location     = obj.GetObject("location", InstagramLocation.Parse);
                media.UsersInPhoto = obj.GetArray("users_in_photo", InstagramTaggedUser.Parse);
            }

            return(media);
        }
        /// <summary>
        /// Gets an instance of <code>FacebookDebugTokenData</code> from the specified <var>JsonObject</var>.
        /// </summary>
        /// <param name="obj">The instance of <code>JsonObject</code> to parse.</param>
        public static FacebookDebugTokenData Parse(JsonObject obj)
        {
            // Check if NULL
            if (obj == null)
            {
                return(null);
            }

            // If an access token doesn't have an expire date, it may be specified as "0". In other scenarios, the
            // property is not present at all. In either case, we should set the "ExpiresAt" property to "NULL".
            DateTime?expiresAt = null;

            if (obj.HasValue("expires_at"))
            {
                int value = obj.GetInt32("expires_at");
                if (value > 0)
                {
                    expiresAt = SocialUtils.GetDateTimeFromUnixTime(value);
                }
            }

            // Parse the array of scopes
            FacebookScope[] scopes = (
                from name in obj.GetArray <string>("scopes") ?? new string[0]
                select FacebookScope.GetScope(name) ?? new FacebookScope(name)
                ).ToArray();

            // Initialize the instance of FacebookDebugTokenData
            return(new FacebookDebugTokenData(obj)
            {
                AppId = obj.GetInt64("app_id"),
                Application = obj.GetString("application"),
                ExpiresAt = expiresAt,
                IsValid = obj.GetBoolean("is_valid"),
                IssuedAt = obj.HasValue("issued_at") ? (DateTime?)obj.GetDateTimeFromUnixTimestamp("issued_at") : null,
                UserId = obj.GetString("user_id"),
                Scopes = scopes
            });
        }
Ejemplo n.º 5
0
 public DateTime GetDateTimeFromUnixTimestamp(string name)
 {
     return(SocialUtils.GetDateTimeFromUnixTime(GetValue <int>(name)));
 }