public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, TraceWriter log) { SocialPost post = await req.Content.ReadAsAsync <SocialPost>(); //string name = productname.Productname; List <EventGridEvent> eventlist = new List <EventGridEvent>(); for (int i = 0; i < 1; i++) { eventlist.Add(new EventGridEvent() { Id = Guid.NewGuid().ToString(), EventType = "integration.event.eventpublished", EventTime = DateTime.Now, Subject = "IntegrationEvent", DataVersion = "1.0", Data = new SocialPost() { PostType = post.PostType, PostedBy = post.PostedBy, PostDescription = post.PostDescription, id = Guid.NewGuid().ToString() } }); } TopicCredentials topicCredentials = new TopicCredentials(eventgridkey); EventGridClient client = new EventGridClient(topicCredentials); client.PublishEventsAsync(topicHostname, eventlist).GetAwaiter().GetResult(); return(req.CreateResponse(HttpStatusCode.OK)); }
/// <summary> /// Iterates through the feeds retrieved for the target user. /// </summary> /// <param name="feed">Collection of Feeds retrieved.</param> /// <param name="feedType">Type of feed.</param> public void IterateThroughFeed(SocialFeed feed, SocialFeedType feedType) { try { SocialThread[] threads = feed.Threads; Deployment.Current.Dispatcher.BeginInvoke(() => { lstFeeds.Items.Clear(); }); foreach (SocialThread thread in threads) { if (thread.ThreadType == SocialThreadType.Normal) { // Get the root post text value and add to the list. SocialPost rootPost = thread.RootPost; Feed objFeed = new Feed(); objFeed.FeedText = rootPost.Text; Deployment.Current.Dispatcher.BeginInvoke(() => { lstFeeds.Items.Add(objFeed); }); } } } catch (Exception ex) { Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show("Error: " + ex.Message); }); } }
void UserCallBack(FBResult result) { Debug.Log("UserCallBack"); if (result.Error != null) { Debug.Log("UserCallBack - user graph request failed: " + result.Error + " - " + result.Text); #if PROPELLER_SDK PropellerSDK.SdkSocialLoginCompleted(null); #endif if (socialPost != SocialPost.NONE) { #if PROPELLER_SDK switch (socialPost) { case SocialPost.INVITE: PropellerSDK.SdkSocialInviteCompleted(); break; case SocialPost.SHARE: PropellerSDK.SdkSocialShareCompleted(); break; } #endif socialPost = SocialPost.NONE; socialPostData = null; } return; } string get_data = result.Text; var dict = Json.Deserialize(get_data) as IDictionary; fbname = dict ["name"].ToString(); fbemail = dict ["email"].ToString(); fbgender = dict ["gender"].ToString(); fbfirstname = dict ["first_name"].ToString(); PushFBDataToFuel(); if (socialPost != SocialPost.NONE) { switch (socialPost) { case SocialPost.INVITE: onSocialInviteClicked(socialPostData); break; case SocialPost.SHARE: onSocialShareClicked(socialPostData); break; } } }
/* * ----------------------------------------------------- * FaceBook Share * ----------------------------------------------------- */ public void onSocialShareClicked(Dictionary <string, string> shareInfo) { Debug.Log("onSocialShareClicked"); /* * string toId = "", * string link = "", * string linkName = "", * string linkCaption = "", * string linkDescription = "", * string picture = "", * string mediaSource = "", * string actionName = "", * string actionLink = "", * string reference = "", * Dictionary<string, string[]> properties = null, * FacebookDelegate callback = null) */ if (FB.IsLoggedIn) { FB.Feed( FB.UserId, shareInfo ["link"], shareInfo ["subject"], shareInfo ["short"], shareInfo ["long"], shareInfo ["picture"], null, null, null, null, null, appFeedCallback); } else { if (socialPost != SocialPost.NONE) { socialPost = SocialPost.NONE; socialPostData = null; #if PROPELLER_SDK PropellerSDK.SdkSocialShareCompleted(); #endif return; } socialPost = SocialPost.SHARE; socialPostData = shareInfo; trySocialLogin(false); } }
public IEnumerable <SocialPost> GetTwitterStatuses(string screenName, int count) { var items = Enumerable.Empty <TwitterStatus>(); try { var service = new TwitterService(consumerKey, consumerSecret); service.AuthenticateWith(accessToken, accessTokenSecret); //do not use ListTweetsOnUserTimelineAsync var task = new Task <IEnumerable <TwitterStatus> >(() => { return(service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions { ScreenName = screenName, Count = count })); }); task.Start(); //execute task in current task scheduler var isFinished = task.Wait(ThirdPartyServicesAPITimeout); if (isFinished && task.IsCompleted) { items = task.Result; } } catch (Exception ex) { //EventLogProvider.LogEvent(EventType.ERROR, "SocialService", "GetTwitterStatuses", // EventLogProvider.GetExceptionLogMessage(ex)); } var posts = new List <SocialPost>(); foreach (var item in items) { var post = new SocialPost { Author = item.User.ScreenName, Message = item.Text, Url = item.ToTwitterUrl().ToString(), ImageUrl = GetTweetImage(item.Entities.Media), Date = item.CreatedDate, Type = SocialTypes.Twitter, }; posts.Add(post); } return(posts); }
/* * ----------------------------------------------------- * Awake * ----------------------------------------------------- */ void Awake() { Debug.Log("Awake"); if (Instance != null && Instance != this) { //destroy other instances Destroy(gameObject); } else if (Instance == null) { #if USE_ANALYTICS flurryService = Flurry.Instance; //AssertNotNull(service, "Unable to create Flurry instance!", this); //Assert(!string.IsNullOrEmpty(_iosApiKey), "_iosApiKey is empty!", this); //Assert(!string.IsNullOrEmpty(_androidApiKey), "_androidApiKey is empty!", this); flurryService.StartSession(_iosApiKey, _androidApiKey); #endif #if PROPELLER_SDK m_listener = new fuelSDKListener(); if (m_listener == null) { throw new Exception(); } #endif m_matchData = new GameMatchData(); m_matchData.ValidMatchData = false; m_matchData.MatchComplete = false; socialPost = SocialPost.NONE; socialPostData = null; useFaceBook = true; useFuelCompete = true; if (useFaceBook) { Debug.Log("FB.Init"); FB.Init(SetInit, OnHideUnity); } } Instance = this; DontDestroyOnLoad(gameObject); }
public ActionResult Post(SocialPost post) { if (!string.IsNullOrWhiteSpace(post.UserId)) { post.IsPublic = false; // Make the post initially viewable only by the owner _db.SocialPosts.Add(post); _db.SaveChanges(); } // Create a session which holds and retain user information. Session["UserId"] = post.UserId; Session["FullName"] = post.FullName; return(RedirectToAction("Index")); }
/* * ----------------------------------------------------- * FaceBook Invite * ----------------------------------------------------- */ public void onSocialInviteClicked(Dictionary <string, string> inviteInfo) { Debug.Log("onSocialInviteClicked"); /* * string message, * string[] to = null, * List<object> filters = null, * string[] excludeIds = null, * int? maxRecipients = null, * string data = "", * string title = "", * FacebookDelegate callback = null) */ if (FB.IsLoggedIn) { FB.AppRequest( inviteInfo ["long"], null, null, null, null, null, inviteInfo ["subject"], appRequestCallback); } else { if (socialPost != SocialPost.NONE) { socialPost = SocialPost.NONE; socialPostData = null; #if PROPELLER_SDK PropellerSDK.SdkSocialInviteCompleted(); #endif return; } socialPost = SocialPost.INVITE; socialPostData = inviteInfo; trySocialLogin(false); } }
void LoginCallback(FBResult result) { Debug.Log("LoginCallback"); if (!FB.IsLoggedIn) { if (result.Error != null) { Debug.Log("LoginCallback - login request failed: " + result.Error); } else { Debug.Log("LoginCallback - login request cancelled"); } #if PROPELLER_SDK PropellerSDK.SdkSocialLoginCompleted(null); #endif if (socialPost != SocialPost.NONE) { #if PROPELLER_SDK switch (socialPost) { case SocialPost.INVITE: PropellerSDK.SdkSocialInviteCompleted(); break; case SocialPost.SHARE: PropellerSDK.SdkSocialShareCompleted(); break; } #endif socialPost = SocialPost.NONE; socialPostData = null; } return; } OnLoggedIn(); }
private List <SocialPost> GetPosts(string accountName) { try { List <SocialPost> posts = new List <SocialPost>(); //Make the request string endpoint = hdnHostWeb.Value + "/_api/social.feed/actor(item='" + accountName + "')/Feed"; XDocument responseDoc = GetDataREST(endpoint); //Parse the response XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices"; XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"; XNamespace georss = "http://www.georss.org/georss"; XNamespace gml = "http://www.opengis.net/gml"; var personalEntries = from e in responseDoc.Root.Descendants(d + "RootPost") select new { Body = e.Element(d + "Text").Value, CreatedDate = DateTime.Parse(e.Element(d + "CreatedTime").Value), LikedByMe = bool.Parse(e.Element(d + "LikerInfo").Element(d + "IncludesCurrentUser").Value) }; //Build a collection of posts foreach (var personalEntry in personalEntries) { SocialPost post = new SocialPost(); post.CreatedDate = personalEntry.CreatedDate; post.Body = personalEntry.Body; post.LikedByMe = personalEntry.LikedByMe; posts.Add(post); } return(posts); } catch { return(new List <SocialPost>()); } }
private List <SocialPost> GetPosts(string accountName) { List <SocialPost> posts = new List <SocialPost>(); using (ClientContext ctx = TokenHelper.GetClientContextWithContextToken(hdnHostWeb.Value, hdnContextToken.Value, Request.Url.Authority)) { try { //Get posts SocialFeedManager feedManager = new SocialFeedManager(ctx); ctx.Load(feedManager); SocialFeedOptions feedOptions = new SocialFeedOptions(); feedOptions.MaxThreadCount = 50; feedOptions.SortOrder = SocialFeedSortOrder.ByCreatedTime; ClientResult <SocialFeed> feedData = feedManager.GetFeedFor(accountName, feedOptions); ctx.ExecuteQuery(); //Build a collection of posts foreach (SocialThread thread in feedData.Value.Threads) { SocialPost post = new SocialPost(); post.CreatedDate = thread.RootPost.CreatedTime; post.Body = thread.RootPost.Text; post.LikedByMe = thread.RootPost.LikerInfo.IncludesCurrentUser; posts.Add(post); } return(posts); } catch { return(new List <SocialPost>()); } } }
public string getCaseSubject(SocialPost post) { return(Self.getCaseSubject(post)); }
// API public InboundSocialPostResult handleInboundSocialPost(SocialPost param1, SocialPersona param2, Map <string, object> param3) { return(Self.handleInboundSocialPost(param1, param2, param3)); }
internal static void CreatePost(SocialPost item, Taxon taxa) { try { var providerName = DynamicModuleManager.GetDefaultProviderName("Telerik.Sitefinity.DynamicTypes.Model.UserGeneratedContent.SocialPost"); // Set a transaction name and get the version manager var transactionName = new Guid().ToString(); var versionManager = VersionManager.GetManager(null, transactionName); DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName, transactionName); Type postType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.UserGeneratedContent.SocialPost"); var itemFilter = String.Format("NetworkUrl = \"{0}\"", item.url); var checkItem = dynamicModuleManager.GetDataItems(postType).Where(itemFilter); if (checkItem.Count() > 0 || item.image.IsNullOrWhitespace()) { return; } dynamicModuleManager.Provider.SuppressSecurityChecks = true; DynamicContent socialPostItem = dynamicModuleManager.CreateDataItem(postType); // This is how values for the properties are set //postItem.SetValue("Title", String.Format("{0}: {1}", item.User.Username, item.Id)); socialPostItem.SetValue("Title", item.image); socialPostItem.SetValue("Text", item.text); socialPostItem.SetValue("Network", item.network); socialPostItem.SetValue("NetworkUrl", item.url); socialPostItem.Organizer.AddTaxa("searchhashtags", taxa.Id); socialPostItem.SetValue("SearchId", item.id); socialPostItem.SetValue("SocialUser", JsonConvert.SerializeObject(item.user, Formatting.Indented)); socialPostItem.SetValue("ImageUrl", item.image); socialPostItem.SetValue("Highlight", false); socialPostItem.SetValue("Type", item.type); var posted = DateTime.UtcNow; DateTime.TryParseExact(item.posted.Replace("+00000", "").Trim(), "yyyy-MM-dd hh:mm:ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out posted); //DateTime.TryParseExact(item.posted.Replace("+00000","").Trim(), "yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out posted); if (posted < DateTime.UtcNow.AddYears(-1)) { posted = DateTime.UtcNow; } socialPostItem.SetValue("Posted", posted); socialPostItem.SetString("UrlName", Guid.NewGuid().ToString()); socialPostItem.SetValue("PublicationDate", DateTime.UtcNow); socialPostItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "AwaitingApproval"); // Create a version and commit the transaction in order changes to be persisted to data store versionManager.CreateVersion(socialPostItem, false); TransactionManager.CommitTransaction(transactionName); dynamicModuleManager.Provider.SuppressSecurityChecks = false; } catch (Exception) { return; } }
public IEnumerable <SocialPost> GetPosts(string pageName, int count) { var items = new List <dynamic>(); try { var task = new Task <object>(() => { var client = new FacebookClient(); dynamic accessToken = client.Get("oauth/access_token", new { client_id = _clientId, client_secret = _clientSecret, grant_type = "client_credentials" }); client.AppId = _clientId; client.AppSecret = _clientSecret; client.AccessToken = accessToken.access_token; return(client.Get(pageName + "/posts", new { limit = count, fields = "id,created_time,from,message,permalink_url,picture" })); // TODO Move facebook page name to config }); dynamic result = null; task.Start(); var isFinished = task.Wait(ThirdPartyServicesAPITimeout); if (isFinished && task.IsCompleted) { result = task.Result; } items = result != null && result.data != null ? result.data : new List <dynamic>(); } catch (Exception ex) { //EventLogProvider.LogEvent(EventType.ERROR, "SocialService", "GetFacebookPosts", // EventLogProvider.GetExceptionLogMessage(ex)); } var posts = new List <SocialPost>(); foreach (var item in items) { var post = new SocialPost { Author = item.from.name, Message = item.message, Url = item.permalink_url, ImageUrl = item.picture, Date = DateTime.Parse((string)item.created_time), Type = SocialTypes.Facebook, }; posts.Add(post); } return(posts); }
public void DeleteInspiration(SocialPost socialPost) { throw new NotImplementedException(); }
private List<SocialPost> GetPosts(string accountName) { try { List<SocialPost> posts = new List<SocialPost>(); //Make the request string endpoint = hdnHostWeb.Value + "/_api/social.feed/actor(item='" + accountName + "')/Feed"; XDocument responseDoc = GetDataREST(endpoint); //Parse the response XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices"; XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"; XNamespace georss = "http://www.georss.org/georss"; XNamespace gml = "http://www.opengis.net/gml"; var personalEntries = from e in responseDoc.Root.Descendants(d + "RootPost") select new { Body = e.Element(d + "Text").Value, CreatedDate = DateTime.Parse(e.Element(d + "CreatedTime").Value), LikedByMe = bool.Parse(e.Element(d + "LikerInfo").Element(d + "IncludesCurrentUser").Value) }; //Build a collection of posts foreach (var personalEntry in personalEntries) { SocialPost post = new SocialPost(); post.CreatedDate = personalEntry.CreatedDate; post.Body = personalEntry.Body; post.LikedByMe = personalEntry.LikedByMe; posts.Add(post); } return posts; } catch { return new List<SocialPost>(); } }
private List<SocialPost> GetPosts(string accountName) { List<SocialPost> posts = new List<SocialPost>(); using (ClientContext ctx = TokenHelper.GetClientContextWithContextToken(hdnHostWeb.Value, hdnContextToken.Value, Request.Url.Authority)) { try { //Get posts SocialFeedManager feedManager = new SocialFeedManager(ctx); ctx.Load(feedManager); SocialFeedOptions feedOptions = new SocialFeedOptions(); feedOptions.MaxThreadCount = 50; feedOptions.SortOrder = SocialFeedSortOrder.ByCreatedTime; ClientResult<SocialFeed> feedData = feedManager.GetFeedFor(accountName, feedOptions); ctx.ExecuteQuery(); //Build a collection of posts foreach (SocialThread thread in feedData.Value.Threads) { SocialPost post = new SocialPost(); post.CreatedDate = thread.RootPost.CreatedTime; post.Body = thread.RootPost.Text; post.LikedByMe = thread.RootPost.LikerInfo.IncludesCurrentUser; posts.Add(post); } return posts; } catch { return new List<SocialPost>(); } } }
public Task <ActionResult <SocialPost> > UpdateSocialPost(SocialPost socialPost) { throw new NotImplementedException(); }
public InboundSocialPostResult handleInboundSocialPost(SocialPost post, SocialPersona persona, Map <string, object> rawData) { return(Self.handleInboundSocialPost(post, persona, rawData)); }