Development Software
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb Site ManagementDevelopment Software

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 2nd, 2011, 05:20 AM
Evostance Evostance is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 55 Evostance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 35 m 45 sec
Reputation Power: 6
Best way to integrate a CMS with Facebook registration?

Im currently designing a website which will do a variation of things.

1) It will give articles to users which reside in different categories.
2) Provide users a section to sign up to discounts.
3) A section where users can get information about products etc
4) Provide target content for the user based upon a registration field.

Now, I have experience with Wordpress so the obvious solution for me is that Wordpress would work for sections 1 + 3.

What I want is for the users to be able to register with Facebook for my site with a custom field. This custom field will be able to provide the user with targeted content for section 4.

So far I have seen Facebook plugins which register the user as a Wordpress user, but this isn't what I am after.

What do you think the best solution for this is? Use Wordpress with a custom database that stores the Facebook information? Or is there a plugin that allows me to do just this?

I also might want to integrate a forum later on which ideally would use the Facebook registration information.

Reply With Quote
  #2  
Old May 2nd, 2011, 07:34 AM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,944 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 10 h 16 m 54 sec
Reputation Power: 7053
What information exactly are you trying to get from Facebook?
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old May 2nd, 2011, 07:39 AM
Evostance Evostance is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 55 Evostance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 35 m 45 sec
Reputation Power: 6
Well I want the user to register with Facebook.

In the form there is a custom field, lets called it CF1.

What I want to be able to keep in my database is the Unique ID from facebook for that user and CF1. Maybe a few other things such as their name a profile picture - however it is my understanding that this is dynamically done and doesn't need to be stored in my database?

This will enable me to target my content towards a user based on the custom field CF1

Reply With Quote
  #4  
Old May 2nd, 2011, 03:20 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,944 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 10 h 16 m 54 sec
Reputation Power: 7053
The feature you're looking for is called "Facebook Connect". This will allow you to place a button on your website, and when the user presses that button it will open a Facebook login form for the user to authenticate using their Facebook account. After authentication, you can use Facebook's JavaScript or PHP APIs to fetch information about the user, including their Facebook user ID. Last time I checked, you were only permitted to store Facebook information for 24 hours, but I don't think this applies to user IDs.

Anyway, your basic workflow is going to be:
1) Use Facebook Connect to authenticate the user with Facebook and get their ID.
2) Send the user to a registration form to fill out CF1.
3) Save that information to the database.

If your application is going to pull data from Facebook like profile pictures then you also need to send the user to Facebook after step (1) to authorize your application and give it permission to do so.

A custom table in the Wordpress database will work just fine for storing this information. I don't really know Wordpress plugins well, but I doubt there will be one that does exactly what you need. You could probably modify one of the existing ones that creates user accounts though. Remove the user creation part and replace it with your custom registration process. These plugins must also get the user's Facebook ID, so there is some overlap in functionality.

Reply With Quote
  #5  
Old May 2nd, 2011, 07:19 PM
Evostance Evostance is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 55 Evostance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 35 m 45 sec
Reputation Power: 6
Thanks, i've managed to do it! However I have an issue while trying to implement it into my Wordpress theme.

I'm getting the error:

Quote:
Fatal error: Cannot redeclare retrieve_fields() (previously declared in /home/students/public_html/wp/wp-content/themes/studentsso/functions.php:4) in /home/students/public_html/wp/wp-content/themes/studentsso/functions.php on line 7


and lines 4-7 are:

Code:
function retrieve_fields($sf) {

    return json_encode($sf);
}




Now, this all works when its not broken down into Wordpress formats.

In my header file I have:
PHP Code:
<?php
require 'functions.php';
require 
'src/facebook.php';
$facebook = new Facebook(array(
            
'appId' => $config["fb_app_id"],
            
'secret' => $config["fb_app_secret"],
            
'cookie' => true,
        ));

$congratulations FALSE;
// capture the $_REQUEST coming to this page and check if it's a new user
check_registration($facebook,$config["fb_fields"]);

$session $facebook->getSession();

$me null;
// Session based API call.
if ($session) {
    try {
        
$uid $facebook->getUser();
        
// We can use a Graph API call from the PHP-SDK
        //$me = $facebook->api('/me');
        // Or just use our Database!
        
$me get_user_by_id($uid);
    } catch (
FacebookApiException $e) {
        
error_log($e);
    }
}

// login or logout url will be needed depending on current user state.
if ($me) {
    
$logoutUrl $facebook->getLogoutUrl();
} else {
    
// we are not using this url in our example
    
$loginUrl $facebook->getLoginUrl();
}

?>
<?php
/**
 * The Header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="main">
 *
 * @package WordPress
 * @subpackage Students
 * @since Students 1.0
 */
?>


<div class="login-status">
            <?php if ($me): ?>
                <div class="profile">
                    <img class="profile-img" src="https://graph.facebook.com/<?php echo $uid?>/picture" alt="" />
                    <span><?php echo $me['name']; ?></span>
                    <a href="<?php echo $logoutUrl?>">
                        <img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif" />
                    </a>
                </div>
            <?php else: ?>
                    <fb:login-button registration-url="<?php echo $config["base_url"]; ?>register.php" />
            <?php endif ?>
            </div>



In the index, I call in the Header and Footer files

And in the footer I have:

Code:
<div id="fb-root"></div>
<script type="text/javascript">
    window.fbAsyncInit = function() {
            FB.init({
                    appId   : '<?php echo $facebook->getAppId(); ?>',
                    session : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it
                    status  : true, // check login status
                    cookie  : true, // enable cookies to allow the server to access the session
                    xfbml   : true // parse XFBML
            });

            // whenever the user logs in, we refresh the page
            FB.Event.subscribe('auth.login', function() {
                    window.location.reload();
            });
    };

    (function() {
            var e = document.createElement('script');
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
    }());
</script>




Like I said, without this being broken into header, index and footer it works perfectly. However now I get that error when its split.

Any ideas?

Reply With Quote
  #6  
Old May 2nd, 2011, 11:14 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,944 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 10 h 16 m 54 sec
Reputation Power: 7053
It looks like you're including or requiring the functions.php file more than once.

Reply With Quote
  #7  
Old May 3rd, 2011, 12:30 PM
Evostance Evostance is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 55 Evostance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 35 m 45 sec
Reputation Power: 6
Quote:
Originally Posted by E-Oreo
It looks like you're including or requiring the functions.php file more than once.


Well I would have thought have thought that too but i've gone over and over it and its not.

The include functions.php line is in the wordpress header though and I think this is the problem. Does Wordpress reload headers or something that could cause this?

However using require_once fixes it, I dont know if this will affect the script

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementDevelopment Software > Best way to integrate a CMS with Facebook registration?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap