Ad

Post Facebook Status Via Laravel App

- 1 answer

I want to allow my users to post their status to facebook via my site.

I'm new to all of this facebook integration. I did some research on it, and I found so much packages, and information about it. It's overwhelming, and not sure which one I should start using.

How would one go about and implement something like this ?

Ad

Answer

This is not really related to Laravel, but I will give you a list of steps involved:

  1. Register your Facebook app on Facebook Developers to obtain app key and secret.

  2. Add a Facebook authorisation page/button somewhere on your website – you need to redirect users to Facebook and ask for permissions to write on their behalf. This is pretty straight forward and there is a big amount of packages available. This one is pretty simple for instance: https://github.com/adamwathan/eloquent-oauth

  3. Once permission is granted, you have to store OAuth secret token somewhere in your application (usually database). If you use the package mentioned above, your tokens will be stored in 'oauth_identities' table of the database.

  4. Whenever the moment that you want to post something arrives, use Facebook PHP SDK (there are some Laravel wrappers, for instance: https://github.com/SammyK/LaravelFacebookSdk) to post a status update using users token.

If you don't plan any extended functionality, you may actually skip Facebook SDK and make simple HTTP POST requests to graph.facebook.com, method is POST and path is '/me/feed', you submit a form variable called 'message' – very simple!

  1. Note that access tokens expire so you need to extend them from time to time.
Ad
source: stackoverflow.com
Ad