0

I need to share image an to my facebook page. I used the following code:

string accessToken = ConfigurationManager.AppSettings["ACCESSTOKEN"].ToString();
string pageId = ConfigurationManager.AppSettings["PAGEID"].ToString();

string ImagePath = Server.MapPath("Images/img.jpg");

FacebookClient fb = new FacebookClient(accessToken);
fb.AppId = ConfigurationManager.AppSettings["APPID"].ToString();
fb.AppSecret = ConfigurationManager.AppSettings["APPSECRET"].ToString();

 var imgstream = File.OpenRead(ImagePath);
 dynamic res = fb.Post(pageId + "/photos", new
 {
  message = "Test Message",
  file = new FacebookMediaStream
  {
    ContentType = "image/jpg",
    FileName = Path.GetFileName(ImagePath)
   }.SetValue(imgstream)
   }); 

It worked and displayed in "Recent posts by other on [page name]" with my name. Im the admin of this page. For me It should display as posted by admin. help me guys!!

4

1 回答 1

0

解决方案 1:

您可以使用流发布方法,这里是示例演示 url 使用此方法也可以共享视频、flash 和 mp3

http://demo.vatlab.net/StreamPublish.aspx

http://sudiptasanyal.blogspot.in/2011/09/share-image-with-facebook-in-aspnet.html

解决方案2:

Graph API 的使用,参考更多关于

http://www.aspsnippets.com/Articles/Share-Image-Photo-Pictures-on-Facebook-in-ASPNet-using-Graph-API.aspx

于 2013-08-24T12:13:27.640 回答