Inheritance: AddonHelper.Addon
		public static JObject DecodeFacebookRequest(string signed_request, Facebook.Apps app)
		{
			string secret = Facebook.FacebookCommon.Common(app).Secret;
			var facebookData = new Dictionary<string, string>();

			var requestArray = signed_request.Split('.');

			var sig = Base64_Url_Decode(requestArray[0]);

			var dataString = Base64_Url_Decode(requestArray[1]);

			var data = JObject.Parse(dataString);

			var algo = data["algorithm"].ToString().Replace("\"", "");

			if (algo != "HMAC-SHA256")
			{
				return null;
			}

			var hmacsha256 = new System.Security.Cryptography.HMACSHA256(Encoding.UTF8.GetBytes(secret));
			hmacsha256.ComputeHash(Encoding.UTF8.GetBytes(requestArray[1]));

			var expected_sig = Encoding.UTF8.GetString(hmacsha256.Hash);

			if (sig != expected_sig)
			{
				return null;
			}

			return data;
		}
Exemple #2
0
 private IEnumerator OnInit(
     InitDelegate onInitComplete,
     string appId,
     bool cookie = false,
     bool logging = true,
     bool status = true,
     bool xfbml = false,
     string channelUrl = "",
     string authResponse = null,
     bool frictionlessRequests = false,
     Facebook.HideUnityDelegate hideUnityDelegate = null)
 {
     // wait until the native dialogs are loaded
     while (fb == null)
     {
         yield return null;
     }
     fb.Init(onInitComplete, appId, cookie, logging, status, xfbml, channelUrl, authResponse, frictionlessRequests, hideUnityDelegate);
     if (status || cookie)
     {
         isLoggedIn = true;
     }
     if (onInitComplete != null)
     {
         onInitComplete();
     }
 }
        public FormAuthenticate(Facebook mainClass, string url)
        {
            InitializeComponent();

            this.mainClass = mainClass;
            this.web.Navigate(url);
        }
 public void AppRequest(
     string message,
     string[] to = null,
     string filters = "",
     string[] excludeIds = null,
     int? maxRecipients = null,
     string data = "",
     string title = "",
     Facebook.APIDelegate callback = null)
 {
     fb.AppRequest(message, to, filters, excludeIds, maxRecipients, data, title, callback);
 }
Exemple #5
0
 public override void Init(
     InitDelegate onInitComplete,
     string appId,
     bool cookie = false,
     bool logging = true,
     bool status = true,
     bool xfbml = false,
     string channelUrl = "",
     string authResponse = null,
     bool frictionlessRequests = false,
     Facebook.HideUnityDelegate hideUnityDelegate = null)
 {
     StartCoroutine(OnInit(onInitComplete, appId, cookie, logging, status, xfbml, channelUrl, authResponse, frictionlessRequests, hideUnityDelegate));
 }
        public void API(
            string query,
            HttpMethod method,
            Facebook.APIDelegate callback = null,
            Dictionary<string, string> formData = null,
            Facebook.ErrorDelegate errorCallback = null)
        {
            if (query.StartsWith("me"))
            {
                FbDebug.Warn("graph.facebook.com/me does not work within the Unity Editor");
            }

            if (!query.Contains("access_token=") && (formData == null || !formData.ContainsKey("access_token")))
            {
                FbDebug.Warn("Without an access_token param explicitly passed in formData, some API graph calls will 404 error in the Unity Editor.");
            }
            fb.API(query, method, callback, formData, errorCallback);
        }
 public override void Init(
     InitDelegate onInitComplete,
     string appId,
     bool cookie = false,
     bool logging = true,
     bool status = true,
     bool xfbml = false,
     string channelUrl = "",
     string authResponse = null,
     bool frictionlessRequests = false,
     Facebook.HideUnityDelegate hideUnityDelegate = null)
 {
     this.isInitialized = true;
     if (onInitComplete != null)
     {
         onInitComplete();
     }
 }
        public static bool PostToLinkedIn(string title, string submittedUrl, string submittedImageUrl)
        {
            string companyId = "10355329";
            string linkedinSharesEndPoint = "https://api.linkedin.com/v1/companies/"+ companyId + "/shares?oauth2_access_token={0}";

            string accessToken = "AQXmrLhp2cUsaax3QtHE7k5YtSxMgyTAhzba-5aFYvREhVp7kvm4FxfkWVM_0_EFGGeZk6GryWDqCGdHbEnDfxSnuqschsQnGE5VSWYRi67rkLm-yhnpJSJXGdPhP6pp2k6VU5x6FZiK75E4u08RedrBcnyL61mF6Rubf6G7mQcSb10CFcQ&format=json HTTP / 1.1";

            //accessToken = "AQWVdIHVNPUnyLHE4mqsGgcoJnauh0ChrATeq7iesnW4WrABtQC_2vRE2o6i3NBd61Zj1BST8yX2xuTyaFs33o07T - 9OmVEVeLiRWIj3xQ - 6JBzMsYJW9D45Uq2safJJJhBSKVDjoqKGFRnda0W5TZ6qEClnA2iaONmIACBmF - cpRKsvtn8&format=json HTTP / 1.1";//"AQVfZEE04LluteLtvO06zY91Olv3RZIEjOS9FR4Ue93HimNhm_uj3mvhvoCUrOFDvxFp5S2HIibGDq0Ls4_ljeDW1z387O413uJbMuYCtnrV - 2fxF2C_POu55FZaB5qDtiIPncqxAIrXuEcF8BRJiexHOuLYwDlPGHOUcLSYtNUl0sE7Kw0&format=json HTTP/1.1";
            title = "åäö ÖÄÅ";
           // title = UrlManager.StringEncodingConvert(title, "ISO-8859-1", "UTF-8");
           
           // title = UrlManager.replaceSymbols(title);

            var requestUrl = String.Format(linkedinSharesEndPoint, accessToken);
            var message = new
            {
                comment = "Testing out the posting on LinkedIn",
                content = new Dictionary<string, string>
                    {
                        { "title", title },
                        { "submitted-url", submittedUrl },
                        {"submitted-image-url" , submittedImageUrl}
                    },
                visibility = new
                {
                    code = "anyone"
                }
            };

            var requestJson = new JavaScriptSerializer().Serialize(message);

            var client = new WebClient();
            var requestHeaders = new NameValueCollection
    {
        { "Content-Type", "application/json" },
        { "x-li-format", "json" }
    };
            client.Encoding = System.Text.Encoding.UTF8;
            client.Headers.Add(requestHeaders);
            var responseJson = client.UploadString(requestUrl, "POST", requestJson);
            var response = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(responseJson);
            return response.ContainsKey("updateKey");
        }
        public FormSettings(Facebook mainClass)
        {
            InitializeComponent();

              this.mainClass = mainClass;

              AuthedMessage();

              {
            string[] parts = mainClass.shortCutDragModifiers.Split('+');
            foreach (string part in parts) {
              switch (part) {
            case "Ctrl": checkDragModCtrl.Checked = true; break;
            case "Alt": checkDragModAlt.Checked = true; break;
            case "Shift": checkDragModShift.Checked = true; break;
              }
            }
              }

              {
            string[] parts = mainClass.shortCutPasteModifiers.Split('+');
            foreach (string part in parts) {
              switch (part) {
            case "Ctrl": checkPasteModCtrl.Checked = true; break;
            case "Alt": checkPasteModAlt.Checked = true; break;
            case "Shift": checkPasteModShift.Checked = true; break;
              }
            }
              }

              mainClass.PopulateKeysCombobox(comboDragKeys);
              mainClass.PopulateKeysCombobox(comboPasteKeys);

              comboDragKeys.SelectedItem = mainClass.shortCutDragKey;
              comboPasteKeys.SelectedItem = mainClass.shortCutPasteKey;
        }
        public void API(
            string query,
            HttpMethod method,
            Facebook.APIDelegate callback = null,
            Dictionary<string, string> formData = null,
            Facebook.ErrorDelegate errorCallback = null)
        {
            FbDebug.Log("Calling API");

            if (!query.StartsWith("/"))
            {
                query = "/" + query;
            }
            string url = IntegratedPluginCanvasLocation.GraphUrl + query;

            // Copy the formData by value so it's not vulnerable to scene changes and object deletions
            Dictionary<string, string> inputFormData = (formData != null) ? CopyByValue(formData) : new Dictionary<string, string>(1);
            if (!inputFormData.ContainsKey(AccessTokenKey))
            {
                inputFormData[AccessTokenKey] = AccessToken;
            }

            StartCoroutine(graphAPI(url, method, callback, inputFormData, errorCallback));
        }
 public void AppRequest(
     string message,
     string[] to = null,
     string filters = "",
     string[] excludeIds = null,
     int? maxRecipients = null,
     string data = "",
     string title = "",
     Facebook.APIDelegate callback = null)
 {
     iosAppRequest(GetCallbackHandle(callback), message, to, to != null?to.Length:0, filters, excludeIds, excludeIds != null?excludeIds.Length:0, maxRecipients.HasValue, maxRecipients.HasValue?maxRecipients.Value:0, data, title);
 }
        private void TakeLoggedInAction(Facebook.FacebookOAuthResult facebookOAuthResult)
        {
            if (facebookOAuthResult == null)
            {
                // the user closed the FacebookLoginDialog, so do nothing.
                // MessageBox.Show("Cancelled!");
                this.Close();
                return;
            }

            // Even though facebookOAuthResult is not null, it could had been an
            // OAuth 2.0 error, so make sure to check IsSuccess property always.
            if (facebookOAuthResult.IsSuccess)
            {
                // since our respone_type in FacebookLoginDialog was token,
                // we got the access_token
                // The user now has successfully granted permission to our app.
                GlobalSetting.FacebookAccessToken = facebookOAuthResult.AccessToken;
            }
            else
            {
                // for some reason we failed to get the access token.
                // most likely the user clicked don't allow.
                MessageBox.Show(facebookOAuthResult.ErrorDescription);
                this.Close();
            }
        }
 private void AddAuthCallback(Facebook.AuthChangeDelegate callback)
 {
     if (callback != null && !authResponseCallbacks.Contains(callback))
     {
         authResponseCallbacks.Add(callback);
     }
 }
 public void Pay(
     string product,
     string action = "purchaseitem",
     int quantity = 1,
     int? quantityMin = null,
     int? quantityMax = null,
     string requestId = null,
     string pricepointId = null,
     string testCurrency = null,
     Facebook.APIDelegate callback = null)
 {
     throw new PlatformNotSupportedException("There is no Facebook Pay Dialog on iOS");
 }
 public void Init(
     InitDelegate onInitComplete,
     string appId,
     bool cookie = false,
     bool logging = true,
     bool status = true,
     bool xfbml = false,
     string channelUrl = "",
     string authResponse = null,
     bool frictionlessRequests = false,
     Facebook.HideUnityDelegate hideUnityDelegate = null)
 {
     iosInit(cookie, logging, status, frictionlessRequests);
     externalInitDelegate = onInitComplete;
 }
 public FacebookDataReader(Facebook.JsonArray json)
 {
     doc = json;
 }
		public static FacebookApplicationElement Common(Facebook.Apps app)
		{
			return _common[app.ToString()];
		}
 private void loginButton_SessionStateChanged(object sender, Facebook.Client.Controls.SessionStateChangedEventArgs e)
 {
     if (e.SessionState == Facebook.Client.Controls.FacebookSessionState.Opened)
     {
         Welcome.Text = "Welcome, ";
         HitMe.Visibility = Windows.UI.Xaml.Visibility.Visible;
         Post.Visibility = Windows.UI.Xaml.Visibility.Visible;
     }
     else
     {
         Welcome.Text = "Please Login";
         HitMe.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
         Post.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
     }
 }
		public FacebookGraphAPI(Facebook.Apps app, long uid, string accessToken)
		{

			Dictionary<string, string> args = null;

			try
			{
				args = FacebookGraphAPI.GetUserFromCookie(app, HttpContext.Current.Request.Cookies);
			}
			catch { }

			if (args != null && args["uid"] != null && args["uid"].Length > 0 && args["uid"] != "0" && long.Parse(args["uid"]) == uid)
			{
				LoggedIn = true;
				Uid = long.Parse(args["uid"]);
				AccessToken = args["access_token"];
			}
			else
			{
				LoggedIn = false;
				Uid = uid;
				AccessToken = accessToken;
			}
		}
        public void API(
            string query,
            HttpMethod method,
            Facebook.APIDelegate callback = null,
            Dictionary<string, string> formData = null,
            Facebook.ErrorDelegate errorCallback = null)
        {
            string[] dictKeys = null;
            string[] dictVals = null;

            if(formData != null && formData.Count > 0)
            {
                dictKeys = new string[formData.Count];
                dictVals = new string[formData.Count];
                int idx = 0;
                foreach( KeyValuePair<string, string> kvp in formData )
                {
                    dictKeys[idx] = kvp.Key;
                    dictVals[idx] = System.String.Copy(kvp.Value);
                    idx++;
                }
            }
            iosCallFbApi(GetCallbackHandle(callback), query, method!=null?method.ToString():null, dictKeys, dictVals, formData!=null?formData.Count:0);
        }
 private void OnSessionStateChanged(object sender, Facebook.Client.Controls.SessionStateChangedEventArgs e)
 {
     this.ContentPanel.Visibility = (e.SessionState == Facebook.Client.Controls.FacebookSessionState.Opened) ?
                                 Visibility.Visible : Visibility.Collapsed;
 }
 public void GetAuthResponse(Facebook.AuthChangeDelegate callback = null)
 {
     AddAuthCallback(callback);
 }
Exemple #23
0
        private void btnGetMyInfo_Click(object sender, EventArgs e)
        {
            Facebook fb = new Facebook(txtAccessToken.Text);
            //var friends = fb.GetConnections("me", "friends", null);
            //  var friends = GetFriendsCount();

            for (int i = 4; i < 100; i++)
            {
                dynamic result1 = fb.Get(i.ToString());
                string id = result1.id;
                string firstName = result1.first_name;
                var lastName = result1.last_name;
            }

            //  FacebookCollection<object> abc = new FacebookCollection<object>();
            /*   
                // using async method */
            fb.GetAsync("/me",
                        result =>
                        {
                            // incase you are using async,
                            // always check if it was successful.
                            if (result.IsSuccessful)
                            {
                                // this prints out the raw json
                              //  MessageBox.Show(result.RawResponse);
                                string test = result.RawResponse;
            // this mite be preferable - the generic version of the result
            var user = result.GetResponseAs<User>();
                                var friends1 = fb.GetConnections(user.Name, "friends", null);
                                foreach (var friend in friends1)
                                {
                                    string abc = friend.ToString();
                                }
                                //Response.Write(friend["name"]);

                                //post to my wall
                                var data = new Dictionary<string, string>();
                                data.Add("message", "testing facebook graph api");
                                var putobject = fb.PutObject(user.Name, "feed", data);
                                MessageBox.Show("Hi " + user.Name);
                            }
                            else
                            {
                                // exception is stored in result.Exception
                                // u can extract the message using result.Exception.Message
                                // or u can get raw facebook json exception using result.Response.
                                MessageBox.Show("Error: " + Environment.NewLine + result.Exception.Message);
                            }
                        });

            // you can also use synchronous version like below
            // Methods not containing Async are treated as synchronous.

            // you can either use generic version or non generic version
            //var user = fb.Get<User>("/me");
            //MessageBox.Show("Hi " + user.Name);

            // non-generic version returns raw JSON string given by Facebook.
            //MessageBox.Show(fb.Get("/me"));

            // example for posting on the wall:
            //string resultPost = fb.Post("/me/feed", new Dictionary<string, string>
            //                        {
            //                            {"message", "testing from FacebookSharp."}
            //                        });
            //MessageBox.Show(resultPost); // this result is the id of the new post

            // example for deleting
            //string resultDelete = fb.Delete("/id");
            //MessageBox.Show(resultDelete);

            // you can also use Parameter Extensions
            // (make sure you add -> using FacebookSharp.Extensions; )
            // https://graph.facebook.com/?fields=id,picture&ids=123741737666932,100001241534829&oauth_token=your_oauth_token.
            // var result = fb.Get(string.Empty,
            //                    new Dictionary<string, string>()
            //                        .SelectFields(new[] { "picture" })
            //                        .SelectIds(new[] { "123741737666932", "100001241534829" })
            //                        .SelectField("id"));
            // You can also do things like .Offset(2).LimitTo(3) and much more.
            // checkout ParameterExtensions.cs file


            // You can also use the old RestApi by calling GetUsingRestApi or GetUsingRestApiAsync
            fb.GetUsingRestApiAsync("status.get", new Dictionary<string, string>().LimitTo(1),
                                    callback =>
                                    {
                                        if (callback.IsSuccessful)
                                        {
                                            MessageBox.Show(callback.RawResponse);
                                        }
                                    });
            // You can also use the Facebook Query Language by calling Query or QueryAsync methods.
            fb.QueryAsync("SELECT name FROM user WHERE uid = me()",
                          result =>
                          {
                              if (result.IsSuccessful)
                              {
                                  MessageBox.Show("Response using FQL: " + result.RawResponse);
                              }
                          });
        }
 public void Login(string scope = "", Facebook.AuthChangeDelegate callback = null)
 {
     if (isLoggedIn)
     {
         FbDebug.Warn("User " + userId + " is already logged in.  You do not need to call Login() again.");
     }
     AddAuthCallback(callback);
     iosLogin(scope);
 }
Exemple #25
0
		private static bool isMobileBrowser() {
			HttpContext context = HttpContext.Current;

			if(context.Request.Browser.IsMobileDevice) {
				return true;
			}
			if(context.Request.ServerVariables["HTTP_X_WAP_PROFILE"] != null) {
				return true;
			}
			if(context.Request.ServerVariables["HTTP_ACCEPT"] != null &&
					context.Request.ServerVariables["HTTP_ACCEPT"].ToLower().Contains("wap")) {
				return true;
			}
			if(context.Request.ServerVariables["HTTP_USER_AGENT"] != null) {
				//Create a list of all mobile types
				string[] mobiles =
						new[]
                        {
                            "240x320", "blackberry", "symbian", "android",
                            "wireless", "nokia", "phone", "iphone"
                        };

				for(int i = 0; i < mobiles.Length; i++) {
					if(context.Request.ServerVariables["HTTP_USER_AGENT"]
							.IndexOf(mobiles[i], StringComparison.InvariantCultureIgnoreCase) >= 0) {
						return true;
					}
				}
			}

			return false;
		}
 public void PublishInstall(string appId, Facebook.APIDelegate callback = null)
 {
     iosFBSettingsPublishInstall(GetCallbackHandle(callback), appId);
 }
 public override void Init(
     InitDelegate onInitComplete,
     string appId,
     bool cookie = false,
     bool logging = true,
     bool status = true,
     bool xfbml = false,
     string channelUrl = "",
     string authResponse = null,
     bool frictionlessRequests = false,
     Facebook.HideUnityDelegate hideUnityDelegate = null)
 {
     string unityUserAgentSuffix = String.Format("Unity.{0}",
                                                 Facebook.FacebookSdkVersion.Build);
     iosInit(appId,
             cookie,
             logging,
             status,
             frictionlessRequests,
             FBSettings.IosURLSuffix,
             unityUserAgentSuffix);
     this.onInitComplete = onInitComplete;
 }
 private int GetCallbackHandle(Facebook.APIDelegate callback)
 {
     currRequestId++;
     OutstandingRequestCallbacks.Add(currRequestId, callback);
     return currRequestId;
 }
        public override void Init(
            InitDelegate onInitComplete,
            string appId,
            bool cookie = false,
            bool logging = true,
            bool status = true,
            bool xfbml = false,
            string channelUrl = "",
            string authResponse = null,
            bool frictionlessRequests = false,
            Facebook.HideUnityDelegate hideUnityDelegate = null)
        {
            //Init Facebook. This will load in UserID and AccessToken if made a previous login.
            FacebookWP8.Init(appId);

            if(FacebookWP8.IsLoggedIn){
                //If Logged in (UserID and Token was saved and valid then set login = true
                //Dll checks if the token if valid.
                isLoggedIn = FacebookWP8.IsLoggedIn; //Only true if token and User are not blank.
                accessToken = FacebookWP8.AccessToken;
                userId = FacebookWP8.UserID;
            }
            else if(FacebookWP8.AccessToken.Length > 0){
                //If Only access token is there, because login with DLL only produces the Acess Token,
                //Then Complete Login
                isLoggedIn = false;
                accessToken = FacebookWP8.AccessToken;
                StartCoroutine(LoginComplete());
            }
            else{
                //If AccessToken and User are blank in FacebookWP8 class then login if false.
                isLoggedIn = false;
            }

            if (onInitComplete != null){
                onInitComplete();
            }
        }
Exemple #30
0
        private void ProcessLike(Facebook.JsonObject like)
        {
            var tempLike = ((dynamic)like);
            
            //if (tempLike.Keys.Contains(CATEGORY_LIST))
            if (HasCategoryList(tempLike))
            {
                var categories = tempLike[CATEGORY_LIST];

                IDictionary<string, object> map = tempLike;
                map.Remove(CATEGORY_LIST);

                _neo4JManager.AddNode(tempLike, "Like");

                foreach (var cat in categories)
                {
                    _neo4JManager.AddNode(cat, "Category");
                    _neo4JManager.AddRelationship("Like", tempLike.id, "Category", cat.id, "categories");

                }
            }
            else
            {
                _neo4JManager.AddNode(tempLike, "Like");
            }

        }
Exemple #31
0
        private void button1_Click(object sender, EventArgs e)
        {
            string requestUriString = "";
            string strToken         = "";

            try
            {
                if (txtSearch.Text == "")
                {
                    MessageBox.Show("Vui Lòng nhập thông tin tìm kiếm", "Thông báo");
                    return;
                }
                strToken = Facebook.Token(_arrController);
                if (strToken == "")
                {
                    MessageBox.Show("Bạn đã hết Quata token để thực thi việc gọi API của Facebook \n Vui lòng nạp Acc mới hay chờ đến ngày hôm sau.", "Thông báo");
                    return;
                }
                ;
                string strNoidungtimkiem = Uri.EscapeDataString(txtSearch.Text);

                switch (tabControl1.SelectedIndex)
                {
                case 1:     /*Page*/
                    requestUriString = string.Format(@"https://graph.facebook.com/search?q={0}&type={1}&limit={2}&fields={3}&access_token={4}", strNoidungtimkiem, "page", LimitTopSearch.Value, Facebook.SelectPage(), strToken);
                    new Waiting((MethodInvoker) delegate {
                        ListFbPageSearch model = TheardFacebookWriter.FbSearchByPage(requestUriString, _arrController, strToken, _gioihantimkiemfb);
                        if (model.FbPageSearch.Count() != 0)
                        {
                            BindgridPage(model);
                            return;
                        }
                    }, "Vui Lòng Chờ...").ShowDialog();

                    break;

                case 0:
                    requestUriString = string.Format(@"https://graph.facebook.com/search?q={0}&type={1}&limit={2}&fields={3}&access_token={4}", strNoidungtimkiem, "user", LimitTopSearch.Value, Facebook.SelectUser(), strToken);
                    new Waiting((MethodInvoker) delegate {
                        ListFbUserSearch model = TheardFacebookWriter.FbSearchByUser(requestUriString, _arrController, strToken, _gioihantimkiemfb);
                        if (model.FbUserSearch.Count() != 0)
                        {
                            BindgridUser(model);
                            //return;
                        }
                    }, "Vui Lòng Chờ...").ShowDialog();
                    break;

                case 2:    /*group*/
                    requestUriString = string.Format(@"https://graph.facebook.com/search?q={0}&limit={1}&fields={2}&type={3}&access_token={4}", strNoidungtimkiem, LimitTopSearch.Value, Facebook.SelectGroup(), "group", strToken);
                    new Waiting((MethodInvoker) delegate {
                        ListFbGroupSearch model = TheardFacebookWriter.FbSearchByGroup(requestUriString, _arrController, strToken, _gioihantimkiemfb);
                        if (model.FbGroupSearch.Count() != 0)
                        {
                            BindgridGroup(model);
                            //return;
                        }
                    }, "Vui Lòng Chờ...").ShowDialog();
                    break;
                }
                MessageBox.Show(string.Format("Đã xử lý"), "Thông Báo");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "button1_Click");
            }
        }