private static bool SendMessage(IEnumerable <long> pushIds, string subject, string templatePath, Dictionary <string, string> tokens) { FacebookOAuthClient oAuth = new FacebookOAuthClient(FacebookApplication.Current); dynamic tokenResponse = oAuth.GetApplicationAccessToken(); string accessToken = tokenResponse.access_token; FacebookWebClient postApp = new FacebookWebClient(accessToken); string body = System.IO.File.ReadAllText(templatePath); tokens.Add("CanvasUrl", FacebookApplication.Current.ReturnUrlPath); foreach (string key in tokens.Keys) { body = body.Replace("{" + key + "}", tokens[key]); } Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("method", "notifications.sendEmail"); parameters.Add("recipients", string.Join(",", pushIds)); parameters.Add("subject", subject); parameters.Add("fbml", body); dynamic messageResult = postApp.Post(parameters); return(true); }
public ActionResult MensagemPost(string message) { var fb = new FacebookWebClient(); dynamic parameters = new ExpandoObject(); parameters.message = message; dynamic result = fb.Post("me/feed", parameters); return(RedirectToAction("Index", new { success = true })); }
public ActionResult PostCook() { var ns = ConfigurationManager.AppSettings["FBAppNamespace"]; var fb = new FacebookWebClient(); dynamic result = fb.Post(string.Format("/me/{0}:{1}", ns, "cook"), new Dictionary <string, object> { { "recipe", Url.Action("Cookie", "Facebook", null, Request.Url.Scheme) } }); return(RedirectToAction("Cookie", new { id = result.id })); }
protected void btnPostToWall_Click(object sender, EventArgs e) { var fb = new FacebookWebClient(); dynamic parameters = new ExpandoObject(); parameters.message = txtMessage.Text; try { dynamic id = fb.Post("me/feed", parameters); lblPostMessageResult.Text = "Message posted successfully"; txtMessage.Text = string.Empty; } catch (FacebookApiException ex) { lblPostMessageResult.Text = ex.Message; } }