Example #1
0
        static void Main(string[] args)
        {
            ConsoleHelper.WriteLineColorGreen("Access Token : " + args[1]);
            ConsoleHelper.WriteLineColorGreen("Album Id : " + args[0]);
            Console.WriteLine();

            var argsData = new ArgumentModel
            {
                AccessToken = args[1],
                AlbumId     = args[0]
            };

            HandleException.Run(() => {
                IHttpClientService connectionClient = new HttpClientService();
                IFacebookCore worker = new FacebookCore(argsData, connectionClient);

                ConsoleHelper.WriteLineColorBlue("Fetching all photo in album ...");
                var allPhotoList = worker.GetAllPhotoList();
                using (var webClient = new WebClient())
                {
                    ConsoleHelper.WriteLineColorBlue("Downloading photo ...");
                    IDownloader downloader = new Downloader(webClient);
                    downloader.StartDownloadFile(allPhotoList);
                }
                Console.WriteLine("Done!");
            });
        }
Example #2
0
        public static ApiComment Map(SocialComment c)
        {
            var comment = c.Map <ApiComment>();

            comment.OwnerPicture = FacebookCore.Picture(c.OwnerFacebookId).ToString();
            return(comment);
        }
Example #3
0
        //
        // GET: /Admin/Users
        public ActionResult Users(Guid?id, short count = 10)
        {
            if (id.HasValue && Guid.Empty != id.Value)
            {
                var profile = profileCore.SearchSingle <ProfileFull>(id.Value, null, null, true);
                if (null != profile)
                {
                    if (!string.IsNullOrWhiteSpace(profile.FacebookAccessToken))
                    {
                        var fbCore = new FacebookCore();
                        if (string.IsNullOrWhiteSpace(profile.Location))
                        {
                            profile.Location = fbCore.Location(profile.FacebookAccessToken);

                            if (!string.IsNullOrWhiteSpace(profile.Location))
                            {
                                profileCore.Save(profile);
                            }
                        }

                        var emails = fbCore.ImportFriends(profile);
                        foreach (var email in emails)
                        {
                            emailCore.FriendSignedUp(email);
                        }
                    }
                }
            }

            return(View(this.adminCore.Profiles(count)));
        }
Example #4
0
        public override void Execute()
        {
            var facebook    = new FacebookCore();
            var profileCore = new ProfileCore();
            var emailCore   = new EmailCore();

            var profiles = profileCore.Search(null, null, null, true, short.MaxValue, int.MaxValue);

            foreach (var profile in profiles)
            {
                try
                {
                    var user = profileCore.SearchSingle <ProfileFull>(profile.Identifier, profile.Key, null, true);
                    if (!string.IsNullOrWhiteSpace(user.FacebookAccessToken) && Guid.Empty != user.Identifier)
                    {
                        var emails = facebook.ImportFriends(user);
                        foreach (var email in emails)
                        {
                            emailCore.NewFriend(email);
                        }
                    }

                    Thread.Sleep(500);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                }
            }
        }
Example #5
0
        public static ApiActivity Map(Activity r)
        {
            var activity = r.Map <ApiActivity>();

            activity.LargeImage  = ImageCore.LargeCdn(r.ImagePathFormat);
            activity.Thumbnail   = ImageCore.ThumbnailCdn(r.ImagePathFormat);
            activity.UserPicture = FacebookCore.Picture(r.UserFacebookId).ToString();
            return(activity);
        }
Example #6
0
        public void Fetch_Api_Test()
        {
            var mockHttp = new MockHttpMessageHandler();

            mockHttp.When("*")
            .Respond("application/json", GenerateRawJson());
            var client = mockHttp.ToHttpClient();
            IHttpClientService httpClient = new HttpClientService(client);
            IFacebookCore      fbApi      = new FacebookCore(new ArgumentModel(), httpClient);
            var expectedResult            = GenerateMockData();
            var actualResult = fbApi.GetAllPhotoList();

            Assert.Equal(expectedResult.Select(x => x.Data).Count(), actualResult.Select(x => x.Data).Count());
        }
Example #7
0
        public void SetThumbnail(string data)
        {
            if (!string.IsNullOrWhiteSpace(data))
            {
                switch (this.Type)
                {
                case Reference.User:
                case Reference.Company:
                    this.Thumbnail = FacebookCore.Picture(long.Parse(data)).ToString();
                    break;

                case Reference.ItemRequest:
                case Reference.Item:
                    this.Thumbnail = ImageCore.ThumbnailCdn(data);
                    break;
                }
            }
        }
Example #8
0
 public static Uri Picture(this IFacebookIdentity identity)
 {
     return(FacebookCore.Picture(identity.FacebookId));
 }