1

我希望使用 winform 应用程序在我的 Facebook 粉丝页面上发布图像,但代码不起作用。FacebookOAuthException发生错误。有谁知道如何处理这个问题?

var fb = new FacebookClient(_accessToken);

dynamic parameters = new ExpandoObject();
        parameters.message = txtMessage.Text;
        parameters.access_token = _accessToken;
        parameters.source = new FacebookMediaObject
        {
            ContentType = "image/jpeg",
            FileName = Path.GetFileName(ofd.FileName)
        }.SetValue(File.ReadAllBytes(ofd.FileName));

        FacebookClient app = new FacebookClient(_accessToken);

var result = app.Post("/" + [page id] + "/feed", parameters);
4

1 回答 1

2

you need to replace this line

var result = app.Post("/" + [page id] + "/feed", parameters);

by

var result = app.Post("/" + [Album id] + "/feed", parameters);

to get album Id you can get from

        string AlbumId;
        dynamic albums = app.Get("me/albums");
        foreach (dynamic albumInfo in albums.data)
        {
          if( albumInfo.name == "Timeline Photos" ) AlbumId=albumInfo.id; break;
        }
于 2012-11-20T13:18:39.890 回答