0
我需要從我的MVC
應用程序發佈照片,Facebook牆壁上的視頻。我得到以下錯誤 (OAuthException - #2500) An active access token must be used to query information about the current user.
在Facebook上發佈照片和視頻牆壁
請幫幫我。請在下面找到我正在使用的代碼。
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);
@Junaith我的問題仍然沒有解決。如果你有任何選擇,請幫助我提出這個問題。 – user2537735
Heyla,你有沒有發現如何做到這一點? –
這個問題已經解決了我。對於postparameters [「access_token」]屬性,我們需要指定將在Graph API Explorer中填充的訪問令牌。 – user2537735