Hi I'm still learning Facebook C# SDK 5.0.3, I`m building a facebook Apps(iFrame). I follow the sample that was attached on the SDK. I successfully run it and I want to extend it by creating a button event that every time the user click the button a "Hello World" will posted to his wall. Here's the code;
protected void btnRegister_Click(object sender, EventArgs e)
{
    try
    {
        var fbApp = new FacebookClient(FacebookContext.Current);
        dynamic result = fbApp.Post("/me/feed", new Dictionary<string, object> { { "message", "Hello World" } });
    }
    catch (Exception ex)
    {
        Response.Write(ex.ToString());
        Msg.Text = "An error may occurred while processing your request, you may try again.";
    }
}
After running this code i`m getting this error
(OAuthException) (OAuthException) An active access token must be used to query information about the current user.
Please note that on my page_load event I can successfully get the user name using the sample on the Sdk package,
public FacebookSession CurrentSession
{
    get { return (new CanvasAuthorizer()).Session; }
}
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //Response.Redirect("Registration-Closed.aspx");
        Panel1.Visible = true;
        Panel2.Visible = false;
        var auth = new CanvasAuthorizer { Perms = "user_about_me,publish_stream,offline_access" };
        if (auth.Authorize())
        {
 开发者_开发百科           ShowFacebookContent();
        }
    }
}
I suspect that i'm not getting the right access token for my button event.
I hope that i works :
var client = new FacebookClient("my_access_token");
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.example.com/article.html";
parameters.picture = "http://www.example.com/article-thumbnail.jpg";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
parameters.description = "Longer description of the link";
parameters.actions = new {
    name = "View on Zombo",
    link = "http://www.zombo.com",
};
parameters.privacy = new {
    value = "ALL_FRIENDS",
};
parameters.targeting = new {
    countries = "US",
    regions = "6,53",
    locales = "6",
};
dynamic result = client.Post("me/feed", parameters);
The ordinary access token will expire after certain minutes.I think your access token has expired before you call the post event.You can renew your access token and then continue
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论