public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo) { try { var request = requestInfo.ToBaseModel(); var obj = JsonHelper.DeserializeJsonToObject <ReplyDeviceIdModel>(request.Content + ""); ConnectSession newClient = MyAppServer.Sessions.FirstOrDefault(s => s.AppSession == session); if (obj != null && !string.IsNullOrWhiteSpace(obj.DeviceId) && newClient != null) { if (newClient.IsThree) { Logger.Error("该设备从三方设备转成非三方设备,请验证!"); } newClient.SetIdState = SetIdState.HadSet; newClient.DeviceId = obj.DeviceId; newClient.IsThree = false; newClient.Send("reply", new SendBaseModel { Content = new ReplyModel { Success = 1 }, FromDeviceId = session.GetAddress(), ToDeviceId = "" }); } } catch (Exception ex) { Logger.Error(ex.Message + ""); } }
private static BaseAuthenticationInfo LocateFacebookResponse() { FacebookAuthenticationInfo authInformation = null; var connectSession = new ConnectSession(Constants.FacebookApplicationKey, Constants.FacebookApplicationSecret); if (connectSession.IsConnected()) { var facebookApi = new Api(connectSession); try { var userInfo = facebookApi.Users.GetInfo(); authInformation = new FacebookAuthenticationInfo(); authInformation.Identifier = userInfo.uid.HasValue ? userInfo.uid.Value.ToString() : String.Empty; authInformation.FirstName = userInfo.first_name; authInformation.LastName = userInfo.last_name; authInformation.Email = userInfo.proxied_email; authInformation.UserName = userInfo.name; authInformation.Provider = providerModule.GetProvider("Facebook"); authInformation.Picture = userInfo.pic; facebookApi.Auth.ExpireSession(); return(authInformation); } catch (FacebookException ex) { return(null); } } return(authInformation); }
public static ConnectSession GetGenericConnectionSession() { var connectSession = new ConnectSession(GeneralConstants.FACEBOOK_API_KEY, GeneralConstants.FACEBOOK_API_SECRET); connectSession.SessionKey = tradelrSettings.Fb_api_session_key; connectSession.UserId = tradelrSettings.Fb_api_session_userid; return(connectSession); }
public FacebookWorker(ITradelrRepository repository, long ownerid, long subdomainid) { session = new ConnectSession(GeneralConstants.FACEBOOK_API_KEY, GeneralConstants.FACEBOOK_API_SECRET); api = new Api(session); this.subdomainid = subdomainid; this.repository = repository; this.ownerid = ownerid; }
public ActionResult Index() { ConnectSession session = new ConnectSession(ConfigurationManager.AppSettings["Facebook_API_Key"], ConfigurationManager.AppSettings["Facebook_API_Secret"]); if (session.IsConnected()) { Api facebook = new Api(session); ViewData["Message"] = "Hello, " + facebook.Users.GetInfo().name; } else { ViewData["Message"] = "Login with Facebook!"; } return(View()); }
private void OnMessage(ConnectSession connectSession) { // Forward message this.maintainConnection = true; this.Send(connectSession, this.connectionAddresses); }
public override void PostInserted(Post post) { // Send post to FaceBook try { ConnectSession session = new ConnectSession(ApiKey, AppSecret); session.SessionKey = SessionKey; if (session.IsConnected()) { Macros macros = new Macros(); Api api = new Api(session); string fullUrl = macros.FullUrl(post.Url); attachment attachment = new attachment(); attachment.name = post.Title; attachment.href = fullUrl; attachment.description = post.Excerpt("", "", "", 200); action_link link = new action_link(); link.href = fullUrl; link.text = "Read the full entry"; List <action_link> links = new List <action_link>(); links.Add(link); if (!String.IsNullOrEmpty(post.ImageUrl)) { attachment_media_image image = new attachment_media_image(); image.src = macros.FullUrl(post.ImageUrl); image.href = fullUrl; image.type = attachment_media_type.image; List <attachment_media> media = new List <attachment_media>(); media.Add(image); attachment.media = media; } foreach (long pageId in this.PageIdList) { try { api.Stream.Publish("", attachment, links, "", pageId); } catch (Exception ex) { Log.Error("Facebook Plugin", "Failed to submit status to Facebook. {0}", ex.Message); } } } else { Log.Error("Facebook Plugin", "Facebook Session ID not valid"); } } catch (Exception ex) { Log.Error("Facebook Plugin", "Failed to submit status to Facebook. {0}", ex.Message); } }
private void OnMessage(ConnectSession message) { this.ReceivedObjects.Add(message); }
private void OnMessage(ConnectSession message) { this.fixClient.Connect(); }