如何获得使用C#SDK访问令牌 [英] How to get an access token using C# SDK
本文介绍了如何获得使用C#SDK访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我更新了Facebook的SDK来6.0.10和一些code是用来工作不工作了。我曾经张贴在用户的墙使用下面的方法。
I updated the Facebook SDK to 6.0.10 and some code that used to work is not working anymore. I used to post on users' wall use the method below.
用于拍摄的AppId
和 AppSecret
,我没有给它任何访问令牌类FacebookClient我的应用程序。
The class FacebookClient used to take the AppId
, and AppSecret
and I didn't gave it any access token for my application.
string uId = "SomeUid";
FacebookClient fb = new FacebookClient(AppId,AppSecret );
string userFeedPath = String.Format("/{0}/feed", uId);
dynamic parameters = new ExpandoObject();
parameters.link = "Test@test";
parameters.message = "test";
try
{
dynamic result = fb.Post(userFeedPath, parameters);
}
catch(Exception ex)
{
}
现在即使我试试这个,
FacebookClient fb = new FacebookClient();
fb.AppId = "1234...";
fb.AppSecret = "76e69e0c334995cecc8c....";
我得到这个错误:
I'm getting this error:
(OAuthException - #200)(#200)该API调用需要有效的APP_ID
(OAuthException - #200) (#200) This API call requires a valid app_id.
我该如何解决这个问题?
How do I fix this problem?
推荐答案
您将需要发出请求,以获得应用程序访问令牌。
You will need to get the app access token by making the request.
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new {
client_id = "app_id",
client_secret = "app_secret",
grant_type = "client_credentials"
});
fb.AccessToken = result.access_token;
这篇关于如何获得使用C#SDK访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文