我需要从我的MVC
应用在Facebook墙上发布照片,视频。我低于错误
(OAuthException - #2500) An active access token must be used to query information about the current user.
请帮帮我。请在下面找到我正在使用的代码。
string appID = string.Empty;
string appSecretCode = string.Empty;
appID = "<<application Id>>";
appSecretCode = "<<app secretcode>>";
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
{
client_id = appID,
client_secret = appSecretCode,
grant_type = "client_credentials",
scope = "publish_stream"
});
string accessToken = result.access_token;
var client = new FacebookClient(accessToken);
var postparameters = new Dictionary<string, object>();
var media = new FacebookMediaObject
{
FileName = @"Bday.jpg",
ContentType = "image/jpeg"
};
byte[] img = System.IO.File.ReadAllBytes(@"C:\Users\user\Desktop\Bday.jpg");
media.SetValue(img);
postparameters["source"] = media;
postparameters["access_token"] = result.access_token;
var result1 = client.Post(String.Format("https://graph.facebook.com/{0}/photos", "<<User ID>>"), postparameters);
答案 0 :(得分:0)
您需要从https://developers.facebook.com/tools/explorer生成访问令牌并尝试:
required AcccountId, pageid
dynamic parameters = new ExpandoObject();
parameters.message =modelList.message;
parameters.subject = modelList.subject;
parameters.account_id = modelList.AcccountId;
imageBytes = byte[] of image
parameters.source = new FacebookMediaObject{
ContentType = imageType,
FileName = Url
}.SetValue(imageBytes);
client.Post(pageid+ "/photos", parameters);
希望它会有所帮助。