I'm really stuck on understanding the steps needed to integrate a plugin i'm building for Wordpress into facebook such that it can post to either the target user's wall or their fan-page wall.
Specifically i'm stuck with understanding OAuth2 and how to implement it. I'm no stranger to REST type API's but it seems some is done at client authentication level and some is done at server level for what I need.
Here's the scenario:
WP Admin downloads and installs plugin, visits configuration page inside wp-admin. Creates a facebook app to gain an AppID and App Secret and pastes them into the relevant boxes in the config screen in the wp-admin page. Authentication and authorisation to post to a wall is needed here Non-expiring token is needed so the server can perpetually do posts as part of its function without re-authenticating (unless the user manually breaks the link of course).
This is where I get stuck in the authentication and authorisation part.
I have a visible user-interactable page that the user clicks on the button to link to facebook.
Do I redirect the user here (taking them away from wp-admin) and then wait for them to return?
I understand that facebook returns a 'code' which I then exchange for a 'token' - is that right?
From some digging about i've discovered i'll need to ask for offline_access.
Once I have the token I think that I can understand the Graph API easily as i'll just pass credentials to facebook at each point I want to write a post.
I'll need to initially enumerate the pages the user is an admin of and allow the wp-admin to then select a specific page from the list - I guess that's also in Graph API as well.
Please can you help de-mistify the authentication/authorisation system, i'm totally new to OAuth2 and never touched the original OAuth either.
Theoretically as i'm in a web-client at the authorisation point I could use the Javascript SDK and use AJAX to update the back-end server maybe?
Thanks in advance. James