Last active
August 29, 2015 14:27
-
-
Save verkaufer/a1c696ec4b8b2b977de8 to your computer and use it in GitHub Desktop.
Associate Facebook Pages With Users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * First, you'll need to have the user (assuming they are logged in to your site and you have a way to get user details) click on * a button to open an "install" action | |
| */ | |
| //This would be a CONST somewhere in your application's config | |
| $appID = 55512345678 | |
| // Define a URL that Facebook will redirect to after the user confirms the tab installation on Facebook's site | |
| $callbackURL = "http://mywebsite.demo/tab/install"; | |
| $installURL = "http://facebook.com/dialog/pagetab?app=". $appID ."&next=".$callbackURL; | |
| /** | |
| * After the user is sent to the $callbackURL, we do the heavy lifting of associating a pageID with the userID | |
| * The $callbackURL will have the tabAdded parameter added like this: | |
| * http://mywebsite.demo/tab/install?tab_added[PAGEIDHERE]=1 | |
| */ | |
| //Extract the pageID from our $_GET parameter | |
| $tab_added = $_GET[‘tab_added’]; | |
| $pageID = key($tab_added); | |
| //Associate with userID. We'll do some Laravel-esque methods here for simplicity sake | |
| DB::table('user_tabs')->insert([ | |
| 'userID' => Auth::user()->id, | |
| 'pageID' => $pageID | |
| ]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment