使用facebook c#SDK发布后未上载图像

使用facebook c#SDK发布后未上载图像,c#,facebook,facebook-graph-api,facebook-c#-sdk,C#,Facebook,Facebook Graph Api,Facebook C# Sdk,我正在使用Facebook c#SDK在用户墙上发布状态和图片 我可以发布状态,但图像未被发布 这是我的密码: [HttpPost] public ActionResult PostPhotoOnWall(HttpPostedFileBase file) { var client = new FacebookClient(); // Post to user's wall var postparameters = new Dict

我正在使用Facebook c#SDK在用户墙上发布状态和图片

我可以发布状态,但图像未被发布

这是我的密码:

[HttpPost]
    public ActionResult PostPhotoOnWall(HttpPostedFileBase file)
    {
        var client = new FacebookClient();

        // Post to user's wall
        var postparameters = new Dictionary<string, object>();

        postparameters["access_token"] = Session["access_token"].ToString();
        postparameters["picture"] = "http://localhost:8691/Content/themes/base/images/12WIPJ50240-2V91.jpg";

        var result = client.Post("/me/feed", postparameters);

        return View("PostPhoto");
    }
[HttpPost]
公共操作结果后照片墙(HttpPostedFileBase文件)
{
var client=new FacebookClient();
//张贴到用户的墙上
var postparameters=新字典();
后参数[“访问令牌”]=会话[“访问令牌”]。ToString();
后参数[“图片”]=”http://localhost:8691/Content/themes/base/images/12WIPJ50240-2V91.jpg”;
var result=client.Post(“/me/feed”,后参数);
返回视图(“后照片”);
}
在用户墙上张贴的状态没有图像


有人能帮我吗。

我解决了,下面是代码

[HttpPost]
    public ActionResult PostPhotoOnWall(HttpPostedFileBase file)
    {
        var filename = Path.GetFileName(file.FileName);

        var client = new FacebookClient();

        // Post to user's wall
        var postparameters = new Dictionary<string, object>();
        var media = new FacebookMediaObject
        {
            FileName = filename,
            ContentType = "image/jpeg"
        };
        var path = Path.Combine(Server.MapPath("~/Content/themes/base/images"),filename);
        file.SaveAs(path);

        byte[] img = System.IO.File.ReadAllBytes(path);
        media.SetValue(img);

      postparameters["source"] = media;
        postparameters["access_token"] = Session["access_token"].ToString();
     //   postparameters["picture"] = "http://localhost:8691/Content/themes/base/images/12WIPJ50240-2V91.jpg";

        var result = client.Post("/me/photos", postparameters);

        return View("PostPhoto");
    }
[HttpPost]
公共操作结果后照片墙(HttpPostedFileBase文件)
{
var filename=Path.GetFileName(file.filename);
var client=new FacebookClient();
//张贴到用户的墙上
var postparameters=新字典();
var media=新的facebookmedia对象
{
FileName=FileName,
ContentType=“图像/jpeg”
};
var path=path.Combine(Server.MapPath(“~/Content/themes/base/images”),文件名);
file.SaveAs(路径);
byte[]img=System.IO.File.ReadAllBytes(路径);
媒体设置值(img);
后参数[“源”]=介质;
后参数[“访问令牌”]=会话[“访问令牌”]。ToString();
//后参数[“图片”]=”http://localhost:8691/Content/themes/base/images/12WIPJ50240-2V91.jpg”;
var result=client.Post(“/me/photos”,后参数);
返回视图(“后照片”);
}

我解决了,下面是代码

[HttpPost]
    public ActionResult PostPhotoOnWall(HttpPostedFileBase file)
    {
        var filename = Path.GetFileName(file.FileName);

        var client = new FacebookClient();

        // Post to user's wall
        var postparameters = new Dictionary<string, object>();
        var media = new FacebookMediaObject
        {
            FileName = filename,
            ContentType = "image/jpeg"
        };
        var path = Path.Combine(Server.MapPath("~/Content/themes/base/images"),filename);
        file.SaveAs(path);

        byte[] img = System.IO.File.ReadAllBytes(path);
        media.SetValue(img);

      postparameters["source"] = media;
        postparameters["access_token"] = Session["access_token"].ToString();
     //   postparameters["picture"] = "http://localhost:8691/Content/themes/base/images/12WIPJ50240-2V91.jpg";

        var result = client.Post("/me/photos", postparameters);

        return View("PostPhoto");
    }
[HttpPost]
公共操作结果后照片墙(HttpPostedFileBase文件)
{
var filename=Path.GetFileName(file.filename);
var client=new FacebookClient();
//张贴到用户的墙上
var postparameters=新字典();
var media=新的facebookmedia对象
{
FileName=FileName,
ContentType=“图像/jpeg”
};
var path=path.Combine(Server.MapPath(“~/Content/themes/base/images”),文件名);
file.SaveAs(路径);
byte[]img=System.IO.File.ReadAllBytes(路径);
媒体设置值(img);
后参数[“源”]=介质;
后参数[“访问令牌”]=会话[“访问令牌”]。ToString();
//后参数[“图片”]=”http://localhost:8691/Content/themes/base/images/12WIPJ50240-2V91.jpg”;
var result=client.Post(“/me/photos”,后参数);
返回视图(“后照片”);
}