Esempio n. 1
0
		public ProfileService ()
		{
			account = AccountStore.Create ().FindAccountsForService ("facebook").FirstOrDefault ();
			fbService = new FacebookService {
				ClientId = AuthHelpers.ClientId
			};
		}
Esempio n. 2
0
		/// <summary>
		/// Create an app and get a ClientId at  
		/// https://developers.facebook.com/apps
		/// </summary>
		void ShareFacebook_Click (object sender, EventArgs ea)
		{
			// 1. Create the service
			var facebook = new FacebookService {
				ClientId = ServiceConstants.FacebookClientId,
				RedirectUrl = new Uri (ServiceConstants.FacebookRedirectUrl)
			};
			Share (facebook);
		}
Esempio n. 3
0
		/// <summary>
		/// Create an app and get a ClientId at  
		/// https://developers.facebook.com/apps
		/// </summary>
		partial void ShareFacebook_TouchUpInside (UIButton sender)
		{
			// 1. Create the service
			var facebook = new FacebookService {
				ClientId = ServiceConstants.FacebookClientId,
				RedirectUrl = new System.Uri (ServiceConstants.FacebookRedirectUrl)
			};
			Share(facebook);
		}
        private void FacebookPost(Account facebookAccount, string message, string clientID, string link)
        {
            var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me"), null, facebookAccount);
            request.GetResponseAsync().ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        Console.WriteLine("Error: " + t.Exception.InnerException.Message);
                        FacebookLoginPost(clientID, message, link);
                    }
                    else
                    {
                        // 1. Create the service
                        var facebook = new FacebookService { ClientId = clientID };

                        facebook.SaveAccount(Forms.Context, facebookAccount);

                        // 2. Create an item to share
                        var item = new Item();
                        item.Text = message;
                        if (link != null)
                        {
                            item.Links.Add(new Uri(link));
                        }
                        Device.BeginInvokeOnMainThread(() =>
                            {
                                // 3. Present the UI on iOS
                                var shareIntent = facebook.GetShareUI((Activity)Forms.Context, item, result =>
                                    {
                                        // result lets you know if the user shared the item or canceled
                                    });
                                Forms.Context.StartActivity(shareIntent);
                            });
                    }
                });
        }
Esempio n. 5
0
        private void FacebookPost(Account facebookAccount, string message, string clientID, string link)
        {
            var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me?"), null, facebookAccount);
            request.GetResponseAsync().ContinueWith(t =>
                {
                    InvokeOnMainThread(() =>
                    {
                        if (t.IsFaulted)
                        {
                            FacebookLoginPost(clientID, message, link);
                        }
                        else
                        {
                            // 1. Create the service
                            var facebook = new FacebookService
                            {
                                ClientId = clientID,
                            };

                            facebook.SaveAccount(facebookAccount);

                            // 2. Create an item to share
                            var item = new Item();
                            item.Text = message;
                            if (!String.IsNullOrEmpty(link) )
                            {
                                item.Links.Add(new Uri(link));
                            }

                            // 3. Present the UI on iOS
                            UIViewController cur_ViewController=(auth_ViewController==null?c_ViewController:auth_ViewController);
                            var shareController = facebook.GetShareUI(item, result =>
                            {
                                            new UIAlertView ("Result",result.ToString(), null, "Ok").Show ();
                                            c_ViewController.DismissViewController(true,null);
                            });
                                    cur_ViewController.PresentViewController(shareController, true, null);
                        }
                    });
                });
        }
Esempio n. 6
0
//		UIImage ImageWithView (UIView view){
//			UIGraphics.BeginImageContextWithOptions (wordCloud.View.Bounds.Size, view.Opaque, 1.0f);
//			view.Layer.RenderInContext (UIGraphics.GetCurrentContext ());
//			UIImage img = UIGraphics.GetImageFromCurrentImageContext ();
//			UIGraphics.EndImageContext ();
//			return img;
//		}

		void ShareOnFacebook ()
		{
			// 1. Create the service
			var facebook = new FacebookService {
				ClientId = "662403690489016",
				RedirectUrl = new Uri ("https://apps.facebook.com/no_dctapps_indexer/")
			};

			// 2. Create an item to share
			var item = new Item { Text = "This is my stuff from indexer as a wordcloud!" };
			item.Links.Add (new Uri ("http://bit.ly/1hEfVgs"));
			item.Images = GetWordCloudAsImage (); 

			// 3. Present the UI on iOS
			var shareController = facebook.GetShareUI (item, result => {
				// result lets you know if the user shared the item or canceled
				ancestor.NavigationController.DismissViewController(true,null);
			});
			ancestor.NavigationController.PresentViewController (shareController, true, null);
		}
Esempio n. 7
0
        private void FacebookPost(Account facebookAccount, string message, string clientID, string link)
        {
            var request = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me"), null, facebookAccount);
            request.GetResponseAsync().ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        Console.WriteLine("Error: " + t.Exception.InnerException.Message);
                        FacebookLoginPost(clientID, message, link);
                    }
                    else
                    {
                        // 1. Create the service
                        var facebook = new FacebookService
                        {
                            ClientId = clientID,
                        };

                        facebook.SaveAccount(facebookAccount);

                        // 2. Create an item to share
                        var item = new Item();
                        item.Text = message;
                        if (link != null)
                        {
                            item.Links.Add(new Uri(link));
                        }

                        // 3. Present the UI on iOS
                        InvokeOnMainThread(() =>
                            {
                                var shareController = facebook.GetShareUI(item, result =>
                                    {
                                        UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null);
                                    });
                                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(shareController, true, null);
                            });
                    }
                });
        }