Post status,image and video to facebok userwall and facebook page
string app_id = "";
string app_secret = "";
string scope = "publish_stream,manage_pages";
if (Request["code"] == null)
{
Response.Redirect(string.Format(
"https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
app_id, Request.Url.AbsoluteUri, scope));
}
else
{
Dictionary<string, string> tokens = new Dictionary<string, string>();
string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",
app_id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret);
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string vals = reader.ReadToEnd();
foreach (string token in vals.Split('&'))
{
//meh.aspx?token1=steve&token2=jake&...
tokens.Add(token.Substring(0, token.IndexOf("=")),
token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
}
}
string access_token = tokens["access_token"];
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("link", "https://www.youtube.com/watch?v=tbcNGOlvPt8");
data.Add("picture", "http://wakpaper.com/large/Firefox_wallpapers_297.jpg");
//data.Add("caption", "ASP Snippets");
//data.Add("name", "ASP Snippets");
data.Add("message", "this is sandeep vemula");
var client = new FacebookClient(access_token);
client.Post("/USER_ID/feed", data);
FacebookClient app = new FacebookClient(access_token);
dynamic result = app.Post("/PAGE_ID/feed", data);
}
YOU CAN DOWNLOAD THE DLL FILES FROM HERE,
https://drive.google.com/file/d/0B7SW5veaomExeTRhSmJ2bGt2emc/edit?usp=sharing
string app_secret = "";
string scope = "publish_stream,manage_pages";
if (Request["code"] == null)
{
Response.Redirect(string.Format(
"https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
app_id, Request.Url.AbsoluteUri, scope));
}
else
{
Dictionary<string, string> tokens = new Dictionary<string, string>();
string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",
app_id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret);
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string vals = reader.ReadToEnd();
foreach (string token in vals.Split('&'))
{
//meh.aspx?token1=steve&token2=jake&...
tokens.Add(token.Substring(0, token.IndexOf("=")),
token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
}
}
string access_token = tokens["access_token"];
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("link", "https://www.youtube.com/watch?v=tbcNGOlvPt8");
data.Add("picture", "http://wakpaper.com/large/Firefox_wallpapers_297.jpg");
//data.Add("caption", "ASP Snippets");
//data.Add("name", "ASP Snippets");
data.Add("message", "this is sandeep vemula");
var client = new FacebookClient(access_token);
client.Post("/USER_ID/feed", data);
FacebookClient app = new FacebookClient(access_token);
dynamic result = app.Post("/PAGE_ID/feed", data);
}
YOU CAN DOWNLOAD THE DLL FILES FROM HERE,
https://drive.google.com/file/d/0B7SW5veaomExeTRhSmJ2bGt2emc/edit?usp=sharing
Comments