简体   繁体   中英

Using Facebook SDK to publish on user feed / wall

I'm trying to understand if it is possible to post on the users' wall from my Facebook application. At the moment I have:

  • One Facebook app with the permission to write on the users' wall
  • A BackEnd with Fairbooks SDK Installed

Actually I'm following this approach:

    public static string GetToken()
    {
        var fb = new Facebook.FacebookClient();
        dynamic result = fb.Get("oauth/access_token", new
        {
            client_id = APP_ID,
            client_secret = APP_S,
            grant_type = "client_credentials"
        });
        return result.access_token;
    }

    public static void Post(string Message, long UserID)
    {
            var token = GetToken();
            var client = new FacebookClient(token);
            client.Post("/" + UserID + "/photos", new { url = "url", caption = Message });
    }

My final goal is to post on facebook when the user interact with my API without client-side popups. Is this possible?

This line of code calls for an application access token

dynamic result = fb.Get("oauth/access_token", new
        {
            client_id = APP_ID,
            client_secret = APP_S,
            grant_type = "client_credentials"
        });

It makes no sense to use this if you haven't first retrieved a user access token in advance. Only then can you make calls on behalf of the user.

My final goal is to post on facebook when the user interact with my API without client-side popups. Is this possible?

This will never be possible by design. All 3rd party applications must invoke a client-side activity for the user in some format. It cannot be automated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM