Automatically post on wall - Facebook Graph API PHP SDK v4 -


i'm building application event can directly post news messages on facebook. i'm trying use de php sdk v4 there parts of login process don't understand (still couldn't find solution after searching several hours).

my problem in login process. first have specify applicaton , give application secret. have login facebook account.

  1. but account should use that? 1 of event? mine? (i'm admin of events page) (this means messages posted mine account while i'm not poster...sounds pretty weird..)
  2. which method should use login facebook? there veriaty of methonds facebookredirectloginhelper(), facebookcanvasloginhelper() or javascript one. far understand these helpers users login facebook accounts , that's not want.

during search found example of making similar system (facebook graph api php sdk v4 - post on page). he/she uses folowing piece of code getting facebook session:

facebooksession::setdefaultapplication('{app id}','{app secret}'); $session = new facebooksession('{page access token}'); 

this suggests don't need login facebook user need page acces token. if understand correctly (correct me if i'm wrong), page acces token, first need user acces token (https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens). user acces token should logged in, , we're question 1 , 2 in beginning of story.

or can page acces token using following api request (according https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens)

get /{user-id}/accounts 

using random user-id long page admin gave user permission generate such token (so user related "user-id" shouldn't logged in while retrieving page acces token?) .

sounds you'll need use following flow:

  1. have page admin log in facebook account. make sure request manage_pages extended permission. give access pages admin.
  2. once grant access app, you'll short lived user access token. exchange long lived user access token.
  3. get list of user's pages /me/accounts. each page have access_token field returned it. these page access tokens. want use long lived user access token list page access tokens returned not have expiration date. live forever! :)
  4. use page access token post wall of page if want post as page. use user access token post wall of page if want post as user.

and facebook query builder might make whole process lot easier. :)

hope helps!


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -